LocalFileSystem
extends EntityBase
in package
implements
FileSystem
This class provides the magic of being validatable.
See EntityBase::$validators if you want to subclass it.
Table of Contents
Interfaces
- FileSystem
- Base class for filesystems
Properties
- $fileListCache : mixed
- $localeCodes : array<string|int, mixed>
- List of locale codes ordered by translation fallback order per Cx instance
- $nestingCount : int
- Counts the nesting level of __call()
- $stringRepresentationBlank : bool
- Whether blank string representations are valid
- $stringRepresentationFields : array<string|int, mixed>
- List of fields that should be available in the string representation
- $stringRepresentationFormat : string
- Sprintf format for the string representation
- $validators : array<string|int, mixed>
- Initialize this array as follows: array( 'columName' => Zend_Validate )
- $virtual : bool
- Defines if an entity is virtual and therefore not persistable.
- $rootPath : mixed
- The path of the file system.
Methods
- __call() : mixed
- Route methods like getName(), getType(), getDirectory(), etc.
- __construct() : mixed
- __get() : mixed
- This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.
- __toString() : string
- Returns this entity's identifying value
- createDirectory() : string
- Creates a new directory
- createFromPath() : LocalFileSystem
- getComponentController() : SystemComponent
- Returns the component controller for this component
- getFileFromPath() : File|false
- Returns the File instance for a given path
- getFileList() : array<string|int, mixed>
- Returns all files withing a given folder (recursively by default)
- getFullPath() : string
- getKeyAsString() : string
- Returns this entity's key
- getLink() : mixed
- getOffsetPath() : mixed
- getRootPath() : string
- Get Root path of the filesystem
- getThumbnails() : mixed
- getTranslatedFieldValue() : mixed
- Returns the value of a translatable field using fallback mechanisms
- initializeValidators() : mixed
- Set $this->validators
- isDirectory() : bool
- Tells whether $file is a directory or not
- isFile() : bool
- Tells whether $file is not a directory
- isImage() : int
- isVirtual() : bool
- Returns the virtuality of the entity
- moveFile() : string
- Moves a file to a new location
- readFile() : string
- Reads content from $file
- removeFile() : string
- Removes the given file from the OS FS
- removeThumbnails() : array<string|int, mixed>
- setRootPath() : mixed
- Set root path of the filesystem
- setVirtual() : mixed
- Set the virtuality of the entity
- utf8EncodeArray() : array<string|int, mixed>
- Applies utf8_encode() to keys and values of an array From: http://stackoverflow.com/questions/7490105/array-walk-recursive-modify-both-keys-and-values
- validate() : mixed
- writeFile() : mixed
- Writes $content to $file, erases all existing content
- array_merge_recursive() : array<string|int, mixed>
- \array_merge_recursive() behaves unexpected with numerical indexes Fix from http://php.net/array_merge_recursive (array_merge_recursive_new)
- getFallbackLocaleCodes() : array<string|int, mixed>
- Returns a list of all locale codes ordered by fallback order
- getStringRepresentationBlank() : bool
- Whether blank string representations are valid
- getStringRepresentationFields() : array<string|int, mixed>
- Returns a list of fields available in the string representation
- getStringRepresentationFormat() : string
- Returns the sprintf() format for the string representation
Properties
$fileListCache
protected
mixed
$fileListCache
$localeCodes
List of locale codes ordered by translation fallback order per Cx instance
protected
static array<string|int, mixed>
$localeCodes
= array()
Array in the form: array(<instanceId> => array(<localeCode>, ...))
Tags
$nestingCount
Counts the nesting level of __call()
protected
static int
$nestingCount
= 0
$stringRepresentationBlank
Whether blank string representations are valid
protected
bool
$stringRepresentationBlank
= false
Whether blank string representations are valid
Tags
$stringRepresentationFields
List of fields that should be available in the string representation
protected
array<string|int, mixed>
$stringRepresentationFields
= array()
List of field names
Tags
$stringRepresentationFormat
Sprintf format for the string representation
protected
string
$stringRepresentationFormat
= ''
Sprintf format string
Tags
$validators
Initialize this array as follows: array( 'columName' => Zend_Validate )
protected
array<string|int, mixed>
$validators
= array()
$virtual
Defines if an entity is virtual and therefore not persistable.
protected
bool
$virtual
= false
Defaults to FALSE - not virtual.
$rootPath
The path of the file system.
private
mixed
$rootPath
Without ending directory separator.
Methods
__call()
Route methods like getName(), getType(), getDirectory(), etc.
public
__call(string $methodName, array<string|int, mixed> $arguments) : mixed
Parameters
- $methodName : string
-
Name of method to call
- $arguments : array<string|int, mixed>
-
List of arguments for the method to call
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Return value of the method to call
__construct()
public
__construct(mixed $path) : mixed
Parameters
- $path : mixed
__get()
This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.
public
__get(mixed $name) : mixed
Parameters
- $name : mixed
Attributes
- #[ReturnTypeWillChange]
__toString()
Returns this entity's identifying value
public
__toString() : string
By default this returns the same as getKeyAsString(), but this method might get overridden by subclasses.
Return values
string —Identifying value for this entity
createDirectory()
Creates a new directory
public
createDirectory(mixed $path, mixed $directory) : string
Parameters
- $path : mixed
-
Path relative to this FS' root
- $directory : mixed
-
Directory name
Tags
Return values
string —Status message
createFromPath()
public
static createFromPath(mixed $path) : LocalFileSystem
Parameters
- $path : mixed
Return values
LocalFileSystemgetComponentController()
Returns the component controller for this component
public
getComponentController() : SystemComponent
Return values
SystemComponentgetFileFromPath()
Returns the File instance for a given path
public
getFileFromPath(mixed $filepath) : File|false
$path needs to be within this FS' root, otherwise this method will return false.
Parameters
- $filepath : mixed
Return values
File|false —File instance for $path of false
getFileList()
Returns all files withing a given folder (recursively by default)
public
getFileList(mixed $directory[, mixed $recursive = true ][, mixed $readonly = false ]) : array<string|int, mixed>
Parameters
- $directory : mixed
-
Path relative to this FS' root
- $recursive : mixed = true
-
(optional) If set to false, recursion is skipped
- $readonly : mixed = false
-
Set to TRUE to make all files and folders readonly
Tags
Return values
array<string|int, mixed> —UTF8 encoded list of file names, see description
getFullPath()
public
getFullPath(File $file) : string
Parameters
- $file : File
Return values
stringgetKeyAsString()
Returns this entity's key
public
final getKeyAsString([string $separator = '/' ]) : string
If this entity has a composite key, the fields are separated by $separator.
Parameters
- $separator : string = '/'
-
(optional) Separator for composite key fields, default "/"
Return values
string —Entity key as string
getLink()
public
getLink(File $file) : mixed
Parameters
- $file : File
getOffsetPath()
public
getOffsetPath() : mixed
getRootPath()
Get Root path of the filesystem
public
getRootPath() : string
Return values
stringgetThumbnails()
public
getThumbnails(mixed $thumbnailList, mixed $extension, mixed $file, mixed $thumbnails) : mixed
Parameters
- $thumbnailList : mixed
- $extension : mixed
- $file : mixed
- $thumbnails : mixed
getTranslatedFieldValue()
Returns the value of a translatable field using fallback mechanisms
public
getTranslatedFieldValue(string $fieldName) : mixed
If the field is not translatable its value is returned anyway. Tries to return the value in the following locales (if non-empty):
- Current locale
- Default locale
- All other locales
Parameters
- $fieldName : string
-
Name of a translatable field
initializeValidators()
Set $this->validators
public
initializeValidators() : mixed
Validators can be found in lib/FRAMEWORK/Validator.class.php These will be executed if validate() is called
isDirectory()
Tells whether $file is a directory or not
public
isDirectory(File $file) : bool
Parameters
- $file : File
-
File to check
Return values
bool —True if $file is a directory, false otherwise
isFile()
Tells whether $file is not a directory
public
isFile(File $file) : bool
Parameters
- $file : File
-
File to check
Return values
bool —True if $file is not a directory, false otherwise
isImage()
public
isImage(mixed $extension) : int
Parameters
- $extension : mixed
Return values
intisVirtual()
Returns the virtuality of the entity
public
isVirtual() : bool
Return values
bool —TRUE if the entity is virtual, otherwise FALSE
moveFile()
Moves a file to a new location
public
moveFile(File $file, mixed $destination) : string
Parameters
- $file : File
-
File to move
- $destination : mixed
-
Destination path (absolute or relative to this FS' root)
Tags
Return values
string —Status message
readFile()
Reads content from $file
public
readFile(File $file) : string
Parameters
- $file : File
-
File to write to
Return values
string —File contents
removeFile()
Removes the given file from the OS FS
public
removeFile(File $file) : string
Parameters
- $file : File
-
File to remove
Tags
Return values
string —Status message
removeThumbnails()
public
removeThumbnails(File $file) : array<string|int, mixed>
Parameters
- $file : File
Return values
array<string|int, mixed>setRootPath()
Set root path of the filesystem
public
setRootPath(string $rootPath) : mixed
Parameters
- $rootPath : string
Tags
setVirtual()
Set the virtuality of the entity
public
setVirtual(bool $virtual) : mixed
Parameters
- $virtual : bool
-
TRUE to set the entity as virtual or otherwise to FALSE
utf8EncodeArray()
Applies utf8_encode() to keys and values of an array From: http://stackoverflow.com/questions/7490105/array-walk-recursive-modify-both-keys-and-values
public
utf8EncodeArray(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
-
Array to encode
Return values
array<string|int, mixed> —UTF8 encoded array
validate()
public
validate() : mixed
Tags
writeFile()
Writes $content to $file, erases all existing content
public
writeFile(File $file, mixed $content) : mixed
Parameters
- $file : File
-
File to write to
- $content : mixed
-
Content to write
array_merge_recursive()
\array_merge_recursive() behaves unexpected with numerical indexes Fix from http://php.net/array_merge_recursive (array_merge_recursive_new)
protected
array_merge_recursive() : array<string|int, mixed>
This method behaves differently than the original since it overwrites already present keys
Return values
array<string|int, mixed> —Recursively merged array
getFallbackLocaleCodes()
Returns a list of all locale codes ordered by fallback order
protected
getFallbackLocaleCodes() : array<string|int, mixed>
- First entry is the current locale
- Second entry is the default locale (if different from current, it's omitted otherwise)
- Then all other locales follow (in no particular order)
Tags
Return values
array<string|int, mixed> —List of locale codes
getStringRepresentationBlank()
Whether blank string representations are valid
protected
getStringRepresentationBlank() : bool
Return values
bool —Whether blank string representations are valid
getStringRepresentationFields()
Returns a list of fields available in the string representation
protected
getStringRepresentationFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of field names
getStringRepresentationFormat()
Returns the sprintf() format for the string representation
protected
getStringRepresentationFormat() : string
Return values
string —sprintf() format string