You are here

protected function HelpTopicsSyntaxTest::listDirectories in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help_topics\Functional\HelpTopicsSyntaxTest::listDirectories()
  2. 9 core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php \Drupal\Tests\help_topics\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.

File

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

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 ($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 (strpos($path, '/tests') === FALSE && strpos($path, '/testing') === FALSE) {
      $directories[$name] = $path . '/help_topics';
    }
  }
  return $directories;
}