Cms\Helpers\File

Source: ~/modules/cms/helpers/File.php

Defines some file-system helpers for the CMS system.

Public methods

public static boolean validateExtension(string $fileName, array $allowedExtensions, boolean $allowEmpty=true)

Validates whether a file has an allowed extension.

Parameters
  • string $fileName - Specifies a path to validate
  • array $allowedExtensions - A list of allowed file extensions
  • boolean $allowEmpty - Determines whether the file extension could be empty.

public static boolean validateName(string $fileName)

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.

Parameters
  • string $fileName - Specifies a path to validate

public static boolean validatePath(string $filePath, integer $maxNesting=2)

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.

Parameters
  • string $filePath - Specifies a path to validate
  • integer $maxNesting - Specifies the maximum allowed nesting level