function DrupalComponentTest::getComponents

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::getComponents()
  2. 8.9.x core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::getComponents()
  3. 10 core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::getComponents()

Data provider.

Return value

array

File

core/tests/Drupal/Tests/Component/DrupalComponentTest.php, line 56

Class

DrupalComponentTest
General tests for \Drupal\Component that can't go anywhere else.

Namespace

Drupal\Tests\Component

Code

public static function getComponents() : array {
    $root_component_path = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))) . '/lib/Drupal/Component';
    $component_paths = [];
    foreach (new \DirectoryIterator($root_component_path) as $file) {
        if ($file->isDir() && !$file->isDot()) {
            $component_paths[$file->getBasename()] = [
                $file->getPathname(),
            ];
        }
    }
    return $component_paths;
}

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