function HelpTopicsSyntaxTest::listDirectories

Same name and namespace in other branches
  1. 9 core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help_topics\Functional\HelpTopicsSyntaxTest::listDirectories()
  2. 10 core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help\Functional\HelpTopicsSyntaxTest::listDirectories()
  3. 11.x core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help\Functional\HelpTopicsSyntaxTest::listDirectories()

Lists the extension help topic directories of a certain type.

Parameters

string $type: The type of extension to list: module, theme, or profile.

Return value

string[] An array of all of the help topic directories for this type of extension, keyed by extension short name.

1 call to HelpTopicsSyntaxTest::listDirectories()
HelpTopicsSyntaxTest::testHelpTopics in core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php
Tests that all Core help topics can be rendered and have good syntax.

File

core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php, line 243

Class

HelpTopicsSyntaxTest
Verifies that all core Help topics can be rendered and comply with standards.

Namespace

Drupal\Tests\help_topics\Functional

Code

protected function listDirectories($type) {
    $directories = [];
    // Find the extensions of this type, even if they are not installed, but
    // excluding test ones.
    $lister = \Drupal::service('extension.list.' . $type);
    foreach (array_keys($lister->getAllAvailableInfo()) as $name) {
        $path = $lister->getPath($name);
        // You can tell test modules because they are in package 'Testing', but
        // test themes are only known by being found in test directories. So...
        // exclude things in test directories.
        if (strpos($path, '/tests') === FALSE && strpos($path, '/testing') === FALSE) {
            $directories[$name] = $path . '/help_topics';
        }
    }
    return $directories;
}

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