You are here

function AnnotatedClassDiscovery::__construct in Plug 7

Same name in this branch
  1. 7 lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery::__construct()
  2. 7 lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery::__construct()

Constructs an AnnotatedClassDiscovery object.

Parameters

string $subdir: Either the plugin's subdirectory, for example 'Plugin/views/filter', or empty string if plugins are located at the top level of the namespace.

\Traversable $root_namespaces: An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations. If $subdir is not an empty string, it will be appended to each namespace.

string $plugin_definition_annotation_name: (optional) The name of the annotation that contains the plugin definition. Defaults to 'Drupal\Component\Annotation\Plugin'.

Overrides AnnotatedClassDiscovery::__construct

File

lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php, line 56
Contains \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery.

Class

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

Namespace

Drupal\Core\Plugin\Discovery

Code

function __construct($subdir, \Traversable $root_namespaces, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin') {
  if ($subdir) {

    // Prepend a directory separator to $subdir,
    // if it does not already have one.
    if ('/' !== $subdir[0]) {
      $subdir = '/' . $subdir;
    }
    $this->directorySuffix = $subdir;
    $this->namespaceSuffix = str_replace('/', '\\', $subdir);
  }
  $this->rootNamespacesIterator = $root_namespaces;
  $plugin_namespaces = array();
  parent::__construct($plugin_namespaces, $plugin_definition_annotation_name);
}