class AnnotatedClassDiscovery

Same name in this branch
  1. 8.x drupal/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery
  2. 8.x drupal/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Component\Plugin\Discovery\AnnotatedClassDiscovery

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

Hierarchy

Expanded class hierarchy of AnnotatedClassDiscovery

22 files declare their use of AnnotatedClassDiscovery
ActionManager.php in drupal/core/lib/Drupal/Core/Action/ActionManager.php
Contains \Drupal\Core\Action\ActionManager.
AggregatorPluginManager.php in drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php
Contains \Drupal\aggregator\Plugin\AggregatorPluginManager.
AnnotatedClassDiscoveryTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
Definition of Drupal\system\Tests\Plugin\Discovery\AnnotatedClassDiscoveryTest.
ArchiverManager.php in drupal/core/lib/Drupal/Core/Archiver/ArchiverManager.php
BlockManager.php in drupal/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php

... See full list

File

drupal/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php, line 15
Definition of Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery.

Namespace

Drupal\Core\Plugin\Discovery
View source
class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {

  /**
   * The module name that defines the plugin type.
   *
   * @var string
   */
  protected $owner;

  /**
   * The plugin type, for example filter.
   *
   * @var string
   */
  protected $type;

  /**
   * An object containing the namespaces to look for plugin implementations.
   *
   * @var \Traversable
   */
  protected $rootNamespacesIterator;

  /**
   * Constructs an AnnotatedClassDiscovery object.
   *
   * @param string $subdir
   *   The plugin's subdirectory, for example views/filter.
   * @param \Traversable $root_namespaces
   *   An object that implements \Traversable which contains the root paths
   *   keyed by the corresponding namespace to look for plugin implementations,
   *   \Plugin\$subdir will be appended to each namespace.
   * @param array $annotation_namespaces
   *   (optional) The namespaces of classes that can be used as annotations.
   *   Defaults to an empty array.
   * @param string $plugin_definition_annotation_name
   *   (optional) The name of the annotation that contains the plugin definition.
   *   Defaults to 'Drupal\Component\Annotation\Plugin'.
   */
  function __construct($subdir, \Traversable $root_namespaces, $annotation_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin') {
    $this->subdir = str_replace('/', '\\', $subdir);
    $this->rootNamespacesIterator = $root_namespaces;
    $annotation_namespaces += array(
      'Drupal\\Component\\Annotation' => DRUPAL_ROOT . '/core/lib',
      'Drupal\\Core\\Annotation' => DRUPAL_ROOT . '/core/lib',
    );
    $plugin_namespaces = array();
    parent::__construct($plugin_namespaces, $annotation_namespaces, $plugin_definition_annotation_name);
  }

  /**
   * {@inheritdoc}
   */
  protected function getPluginNamespaces() {
    $plugin_namespaces = array();
    foreach ($this->rootNamespacesIterator as $namespace => $dir) {
      $plugin_namespaces["{$namespace}\\Plugin\\{$this->subdir}"] = array(
        $dir,
      );
    }
    return $plugin_namespaces;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AnnotatedClassDiscovery::$annotationNamespaces protected property The namespaces of classes that can be used as annotations.
AnnotatedClassDiscovery::$owner protected property The module name that defines the plugin type.
AnnotatedClassDiscovery::$pluginDefinitionAnnotationName protected property The name of the annotation that contains the plugin definition.
AnnotatedClassDiscovery::$pluginNamespaces protected property The namespaces within which to find plugin classes.
AnnotatedClassDiscovery::$rootNamespacesIterator protected property An object containing the namespaces to look for plugin implementations.
AnnotatedClassDiscovery::$type protected property The plugin type, for example filter.
AnnotatedClassDiscovery::getAnnotationNamespaces protected function Returns an array of PSR-0 namespaces to search for annotation classes.
AnnotatedClassDiscovery::getDefinition public function Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinition(). Overrides DiscoveryInterface::getDefinition
AnnotatedClassDiscovery::getDefinitions public function Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). Overrides DiscoveryInterface::getDefinitions 1
AnnotatedClassDiscovery::getPluginNamespaces protected function Returns an array of PSR-0 namespaces to search for plugin classes. Overrides AnnotatedClassDiscovery::getPluginNamespaces
AnnotatedClassDiscovery::__construct function Constructs an AnnotatedClassDiscovery object. Overrides AnnotatedClassDiscovery::__construct