protected function 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ExtensionDiscovery.php/function/ExtensionDiscovery::filterByProfileDirectories/8.1.x