public static function RealisticDummyContentEnvironment::getAllFileGroups in Realistic Dummy Content 8.2
Same name and namespace in other branches
- 7.2 api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::getAllFileGroups()
- 3.x api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::getAllFileGroups()
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
string $filepath: An absolute filepath on the system, for example /path/to/drupal/sites/all/ modules/mymodule/realistic_dummy_content/fields/node/article/body.
array $extensions: An array of extensions which should be taken into consideration.
Return value
array An empty array in case of an error, or an array of objects of type RealisticDummyContentFileGroup.
1 call to RealisticDummyContentEnvironment::getAllFileGroups()
- RealisticDummyContentAttribute::getCandidateFiles in api/
src/ includes/ RealisticDummyContentAttribute.php - Get all candidate files for a given field for this entity.
File
- api/
src/ includes/ RealisticDummyContentEnvironment.php, line 161
Class
- RealisticDummyContentEnvironment
- The abstract base environment.
Namespace
Drupal\realistic_dummy_content_api\includesCode
public 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 RealisticDummyContentFileGroup($radical, isset($attributes['file']) ? $attributes['file'] : NULL, isset($attributes['attributes']) ? $attributes['attributes'] : array());
}
return $return;
} catch (Exception $e) {
return array();
}
}