static function Environment::GetAllFileGroups in Realistic Dummy Content 8
Returns all files with a given extension for a given filepath.
Files do not always have a one-to-one relationship with the filesystem. For example:
will be represented as three files, but
1.txt 2.txt 2.txt.attribute.txt 2.txt.attribute1.txt 3.txt
will also be represented as three files, but the second one will have two attributes, attribute and attribute1.
Parameters
$filepath: An absolute filepath on the system, for example /path/to/drupal/sites/all/ modules/mymodule/realistic_dummy_content/fields/node/article/body
$extensions: An array of extensions which should be taken into consideration.
Return value
An empty array in case of an error, or an array of objects of type FileGroup.
1 call to Environment::GetAllFileGroups()
- Attribute::GetCandidateFiles in api/
src/ attributes/ Attribute.php - Get all candidate files for a given field for this entity.
File
- api/
src/ environments/ Environment.php, line 152 - Define autoload class.
Class
- Environment
- The abstract base environment.
Namespace
Drupal\realistic_dummy_content_api\environmentsCode
static function GetAllFileGroups($filepath, $extensions) {
try {
$candidate_files = file_scan_directory($filepath, '/.*$/', array(
'key' => 'filename',
));
$files = self::SortCandidateFiles($candidate_files, $extensions);
$return = array();
foreach ($files as $radical => $attributes) {
$return[] = new FileGroup($radical, isset($attributes['file']) ? $attributes['file'] : NULL, isset($attributes['attributes']) ? $attributes['attributes'] : array());
}
return $return;
} catch (\Exception $e) {
return array();
}
}