ExtensionDiscovery::filterByProfileDirectories

protected ExtensionDiscovery::filterByProfileDirectories(array $all_files)

Filters out extensions not belonging to the scanned installation profiles.

Parameters

\Drupal\Core\Extension\Extension[] $all_files.: The list of all extensions.

Return value

\Drupal\Core\Extension\Extension[] The filtered list of extensions.

File

core/lib/Drupal/Core/Extension/ExtensionDiscovery.php, line 290

Class

ExtensionDiscovery
Discovers available extensions in the filesystem.

Namespace

Drupal\Core\Extension

Code

protected function filterByProfileDirectories(array $all_files) {
  if (empty($this->profileDirectories)) {
    return $all_files;
  }

  $all_files = array_filter($all_files, function($file) {
    if (strpos($file->subpath, 'profiles') !== 0) {
      // This extension doesn't belong to a profile, ignore it.
      return TRUE;
    }

    foreach ($this->profileDirectories as $weight => $profile_path) {
      if (strpos($file->getPath(), $profile_path) === 0) {
        // Parent profile found.
        return TRUE;
      }
    }

    return FALSE;
  });

  return $all_files;
}
doc_Drupal
2016-10-29 09:09:41
Comments
Leave a Comment

Please login to continue.