function drupal_phpunit_find_extension_directories in Drupal 9
Same name and namespace in other branches
- 8 core/tests/bootstrap.php \drupal_phpunit_find_extension_directories()
- 10 core/tests/bootstrap.php \drupal_phpunit_find_extension_directories()
Finds all valid extension directories recursively within a given directory.
Parameters
string $scan_directory: The directory that should be recursively scanned.
Return value
array An associative array of extension directories found within the scanned directory, keyed by extension name.
2 string references to 'drupal_phpunit_find_extension_directories'
- drupal_phpunit_populate_class_loader in core/
tests/ bootstrap.php - Populate class loader with additional namespaces for tests.
- TestSuiteBase::findExtensionDirectories in core/
tests/ TestSuites/ TestSuiteBase.php - Finds extensions in a Drupal installation.
File
- core/
tests/ bootstrap.php, line 23 - Autoloader for Drupal PHPUnit testing.
Code
function drupal_phpunit_find_extension_directories($scan_directory) {
$extensions = [];
$dirs = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($scan_directory, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
foreach ($dirs as $dir) {
if (strpos($dir
->getPathname(), '.info.yml') !== FALSE) {
// Cut off ".info.yml" from the filename for use as the extension name. We
// use getRealPath() so that we can scan extensions represented by
// directory aliases.
$extensions[substr($dir
->getFilename(), 0, -9)] = $dir
->getPathInfo()
->getRealPath();
}
}
return $extensions;
}