function HelpTopicsSyntaxTest::listDirectories

Same name in other branches
  1. 9 core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help_topics\Functional\HelpTopicsSyntaxTest::listDirectories()
  2. 8.9.x core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help_topics\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/tests/src/Functional/HelpTopicsSyntaxTest.php
Tests that all Core help topics can be rendered and have good syntax.

File

core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php, line 305

Class

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

Namespace

Drupal\Tests\help\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 ($lister->getAllAvailableInfo() as $name => $info) {
        // Skip obsolete and deprecated modules.
        if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE || $info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
            continue;
        }
        $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 (!str_contains($path, '/tests') && !str_contains($path, '/testing')) {
            $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.