You are here

public static function RealisticDummyContentEnvironment::implementSortCandidateFiles in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::implementSortCandidateFiles()
  2. 7.2 api/src/includes/RealisticDummyContentEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment::implementSortCandidateFiles()

Given a list of candidate files, sort them by names and parts.

Parameters

array $candidate_files: An array keyed by filename which contains drupal file objects. See SortCandidateFiles().

array $extensions: (Default is NULL). If set, extensions to filter by. See SortCandidateFiles().

Return value

array A sorted array. See SortCandidateFiles().

Throws

\Exception

1 call to RealisticDummyContentEnvironment::implementSortCandidateFiles()
RealisticDummyContentEnvironment::sortCandidateFiles in api/src/includes/RealisticDummyContentEnvironment.php
Given a list of candidate files, sort them by names and parts.

File

api/src/includes/RealisticDummyContentEnvironment.php, line 248

Class

RealisticDummyContentEnvironment
The abstract base environment.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public static function implementSortCandidateFiles(array $candidate_files, array $extensions = NULL) {
  $return = [];
  foreach ($candidate_files as $candidate_filename => $candidate_file) {
    if (self::validCandidateFilename($candidate_filename, $extensions)) {
      self::addFileToArray($return, $candidate_filename, $candidate_file);
    }
  }

  // We expect the files to be sorted alphabetically, which is not the case on
  // all systems.
  ksort($return);
  return $return;
}