function drupal_phpunit_find_extension_directories

Same name and namespace in other branches
  1. 9 core/tests/bootstrap.php \drupal_phpunit_find_extension_directories()
  2. 8.9.x core/tests/bootstrap.php \drupal_phpunit_find_extension_directories()
  3. 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 26

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 (str_contains($dir->getPathname(), '.info.yml')) {
            // 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.