File
Defines some file-system helpers for the CMS system.
class Cms\Helpers\File
Methods
public
static
validateExtension (string $fileName, array $allowedExtensions, boolean $allowEmpty = true
)
: bool
Validates whether a file has an allowed extension.
Property | Type | Description |
---|---|---|
$fileName | string |
string
Specifies a path to validate |
$allowedExtensions | array |
array
A list of allowed file extensions |
$allowEmpty | boolean |
boolean
Determines whether the file extension could be empty. |
Returns true if the file extension is valid. Otherwise returns false.
public static validateName (string $fileName) : bool
Validates a CMS object file or directory name.
CMS object file names can contain only alphanumeric symbols, dashes, underscores and dots. Name can also begin with a component name, eg: MyComponent::filename.
Property | Type | Description |
---|---|---|
$fileName | string |
string
Specifies a path to validate |
Returns true if the file name is valid. Otherwise returns false.
public
static
validatePath (string $filePath, integer $maxNesting = 2
)
: bool
Validates a CMS object path.
CMS object directory and file names can contain only alphanumeric symbols, dashes and dots. CMS objects support only a single level of subdirectories.
Property | Type | Description |
---|---|---|
$filePath | string |
string
Specifies a path to validate |
$maxNesting | integer |
integer
Specifies the maximum allowed nesting level |
Returns true if the file name is valid. Otherwise returns false.