You are here

protected function AnnotatedClassDiscovery::getPluginNamespaces in Drupal 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery::getPluginNamespaces()
  2. 8 core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery::getPluginNamespaces()
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery::getPluginNamespaces()
  2. 10 core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery::getPluginNamespaces()

Gets an array of PSR-4 namespaces to search for plugin classes.

Return value

string[]

Overrides AnnotatedClassDiscovery::getPluginNamespaces

1 call to AnnotatedClassDiscovery::getPluginNamespaces()
AnnotatedClassDiscoveryAutomatedProviders::getDefinitions in core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
Gets the definition of all plugins for this type.

File

core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php, line 114

Class

AnnotatedClassDiscovery
Defines a discovery mechanism to find annotated plugins in PSR-4 namespaces.

Namespace

Drupal\Core\Plugin\Discovery

Code

protected function getPluginNamespaces() {
  $plugin_namespaces = [];
  if ($this->namespaceSuffix) {
    foreach ($this->rootNamespacesIterator as $namespace => $dirs) {

      // Append the namespace suffix to the base namespace, to obtain the
      // plugin namespace; for example, 'Drupal\Views' may become
      // 'Drupal\Views\Plugin\Block'.
      $namespace .= $this->namespaceSuffix;
      foreach ((array) $dirs as $dir) {

        // Append the directory suffix to the PSR-4 base directory, to obtain
        // the directory where plugins are found. For example,
        // DRUPAL_ROOT . '/core/modules/views/src' may become
        // DRUPAL_ROOT . '/core/modules/views/src/Plugin/Block'.
        $plugin_namespaces[$namespace][] = $dir . $this->directorySuffix;
      }
    }
  }
  else {

    // Both the namespace suffix and the directory suffix are empty,
    // so the plugin namespaces and directories are the same as the base
    // directories.
    foreach ($this->rootNamespacesIterator as $namespace => $dirs) {
      $plugin_namespaces[$namespace] = (array) $dirs;
    }
  }
  return $plugin_namespaces;
}