function drupal_phpunit_contrib_extension_directory_roots
Same name in other branches
- 9 core/tests/bootstrap.php \drupal_phpunit_contrib_extension_directory_roots()
- 8.9.x core/tests/bootstrap.php \drupal_phpunit_contrib_extension_directory_roots()
- 11.x core/tests/bootstrap.php \drupal_phpunit_contrib_extension_directory_roots()
Returns directories under which contributed extensions may exist.
Parameters
string $root: (optional) Path to the root of the Drupal installation.
Return value
array An array of directories under which contributed extensions may exist.
2 calls to drupal_phpunit_contrib_extension_directory_roots()
- 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 46
Code
function drupal_phpunit_contrib_extension_directory_roots($root = NULL) {
if ($root === NULL) {
$root = dirname(__DIR__, 2);
}
$paths = [
$root . '/core/modules',
$root . '/core/profiles',
$root . '/core/themes',
$root . '/modules',
$root . '/profiles',
$root . '/themes',
];
$sites_path = $root . '/sites';
// Note this also checks sites/../modules and sites/../profiles.
foreach (scandir($sites_path) as $site) {
if ($site[0] === '.' || $site === 'simpletest') {
continue;
}
$path = "{$sites_path}/{$site}";
$paths[] = is_dir("{$path}/modules") ? realpath("{$path}/modules") : NULL;
$paths[] = is_dir("{$path}/profiles") ? realpath("{$path}/profiles") : NULL;
$paths[] = is_dir("{$path}/themes") ? realpath("{$path}/themes") : NULL;
}
return array_filter($paths);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.