You are here

static function RealisticDummyContentEnvironment::GetAllFileGroups in Realistic Dummy Content 7

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:

1.txt 2.txt 3.txt

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 RealisticDummyContentFileGroup.

1 call to RealisticDummyContentEnvironment::GetAllFileGroups()
RealisticDummyContentAttribute::GetCandidateFiles in api/includes/RealisticDummyContentAttribute.inc
Get all candidate files for a given field for this entity.

File

api/includes/RealisticDummyContentEnvironment.inc, line 146
Define RealisticDummyContentLiveEnvironment autoload class.

Class

RealisticDummyContentEnvironment
The abstract base environment.

Code

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();
  }
}