ExtensionDiscovery
class ExtensionDiscovery (View source)
Discovers available extensions in the filesystem.
To also discover test modules, add
Constants
| ORIGIN_CORE |
Origin directory weight: Core. |
| ORIGIN_PROFILE |
Origin directory weight: Installation profile. |
| ORIGIN_SITES_ALL |
Origin directory weight: sites/all. |
| ORIGIN_ROOT |
Origin directory weight: Site-wide directory. |
| ORIGIN_PARENT_SITE |
Origin directory weight: Parent site directory of a test site environment. |
| ORIGIN_SITE |
Origin directory weight: Site-specific directory. |
| PHP_FUNCTION_PATTERN |
Regular expression to match PHP function names. |
Properties
| static protected array | $files | Previously discovered files keyed by origin directory and extension type. |
|
| protected array | $profileDirectories | List of installation profile directories to additionally scan. |
|
| protected string | $root | The app root for the current operation. |
|
| protected FileCacheInterface | $fileCache | The file cache object. |
|
| protected string | $sitePath | The site path. |
Methods
Constructs a new ExtensionDiscovery object.
Discovers available extensions of a given type.
Sets installation profile directories based on current site settings.
Gets the installation profile directories to be scanned.
Sets explicit profile directories to scan.
Filters out extensions not belonging to the scanned installation profiles.
Recursively scans a base directory for the extensions it contains.
Details
__construct(string $root, bool $use_file_cache = TRUE, array $profile_directories = NULL, string $site_path = NULL)
Constructs a new ExtensionDiscovery object.
Extension[]
scan(string $type, bool $include_tests = NULL)
Discovers available extensions of a given type.
Finds all extensions (modules, themes, etc) that exist on the site. It searches in several locations. For instance, to discover all available modules:
$this
setProfileDirectoriesFromSettings()
Sets installation profile directories based on current site settings.
array
getProfileDirectories()
Gets the installation profile directories to be scanned.
$this
setProfileDirectories(array $paths = NULL)
Sets explicit profile directories to scan.
protected Extension[]
filterByProfileDirectories(array $all_files)
Filters out extensions not belonging to the scanned installation profiles.
protected Extension[]
sort(array $all_files, array $weights)
Sorts the discovered extensions.
protected Extension[]
process(array $all_files)
Processes the filtered and sorted list of extensions.
Extensions discovered in later search paths override earlier, unless they are not compatible with the current version of Drupal core.
protected array
scanDirectory(string $dir, bool $include_tests)
Recursively scans a base directory for the extensions it contains.