You are here

public function AnnotatedClassDiscovery::__construct in Drupal 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery::__construct()
  2. 8 core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery::__construct()
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\Core\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'.

string[] $annotation_namespaces: (optional) Additional namespaces to scan for annotation definitions.

Overrides AnnotatedClassDiscovery::__construct

1 call to AnnotatedClassDiscovery::__construct()
AnnotatedClassDiscoveryAutomatedProviders::__construct in core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
Constructs an AnnotatedClassDiscoveryAutomatedProviders object.
1 method overrides AnnotatedClassDiscovery::__construct()
AnnotatedClassDiscoveryAutomatedProviders::__construct in core/modules/migrate/src/Plugin/Discovery/AnnotatedClassDiscoveryAutomatedProviders.php
Constructs an AnnotatedClassDiscoveryAutomatedProviders object.

File

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

Class

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

Namespace

Drupal\Core\Plugin\Discovery

Code

public function __construct($subdir, \Traversable $root_namespaces, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin', array $annotation_namespaces = []) {
  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 = [];
  parent::__construct($plugin_namespaces, $plugin_definition_annotation_name, $annotation_namespaces);
}