SilverStripe\EnvironmentCheck\Checks\FileAccessibilityAndValidationCheck
Checks for the accessibility and file type validation of one or more files or folders.
Examples:
// Checks /assets/calculator_files has .json files and all files are valid json files.
EnvironmentCheckSuite::register(
'check',
'FileAccessibilityAndValidationCheck(
"' . BASE_PATH . '/assets/calculator_files/*.json",
"jsonValidate",
'.FileAccessibilityAndValidationCheck::CHECK_ALL.'
)',
'Check a json file exist and are all valid json files'
);
// Checks /assets/calculator_files/calculator.json exists and is valid json file.
EnvironmentCheckSuite::register(
'check',
'FileAccessibilityAndValidationCheck(
"' . BASE_PATH . '/assets/calculator_files/calculator.json",
"jsonValidate",
'.FileAccessibilityAndValidationCheck::CHECK_SINGLE.'
)',
'Check a calculator.json exists and is valid json file'
);
// Check only existence
EnvironmentCheckSuite::register(
'check',
'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/calculator.json")',
'Check a calculator.json exists only'
);
Synopsis
- // constants
- const CHECK_SINGLE = 1;
- const CHECK_ALL = 2;
- // members
- protected $path;
- protected $fileTypeValidateFunc;
- protected $checkType;
- // methods
- public void __construct()
- public array check()
- private bool jsonValidate()
- protected bool noVidation()
- protected array getFiles()
Hierarchy
Constants
Name | Value |
---|---|
CHECK_SINGLE | 1 |
CHECK_ALL | 2 |
ERROR | 3 |
WARNING | 2 |
OK | 1 |
Members
protected
- $checkType
—
int
Constant, check for a single file to match age criteria, or all of them. - $fileTypeValidateFunc
—
int
Constant, check for a single file to match age criteria, or all of them. - $path
—
string
Absolute path to a file or folder, compatible with glob().
Methods
private
protected
- getFiles() — Gets a list of absolute file paths.
- noVidation()
public
- __construct()
- check() — {@inheritDoc}