function AttributeClassDiscovery::__construct

Same name in this branch
  1. 10 core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery::__construct()
Same name in other branches
  1. 11.x core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery::__construct()
  2. 11.x core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Component\Plugin\Discovery\AttributeClassDiscovery::__construct()

Constructs an AttributeClassDiscovery 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 $rootNamespacesIterator: 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 $pluginDefinitionAttributeName: (optional) The name of the attribute that contains the plugin definition. Defaults to 'Drupal\Component\Plugin\Attribute\Plugin'.

Overrides AttributeClassDiscovery::__construct

1 call to AttributeClassDiscovery::__construct()
AttributeDiscoveryWithAnnotations::__construct in core/lib/Drupal/Core/Plugin/Discovery/AttributeDiscoveryWithAnnotations.php
Constructs an AttributeDiscoveryWithAnnotations object.
1 method overrides AttributeClassDiscovery::__construct()
AttributeDiscoveryWithAnnotations::__construct in core/lib/Drupal/Core/Plugin/Discovery/AttributeDiscoveryWithAnnotations.php
Constructs an AttributeDiscoveryWithAnnotations object.

File

core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php, line 45

Class

AttributeClassDiscovery
Defines a discovery mechanism to find plugins using attributes.

Namespace

Drupal\Core\Plugin\Discovery

Code

public function __construct(string $subdir, \Traversable $rootNamespacesIterator, string $pluginDefinitionAttributeName = 'Drupal\\Component\\Plugin\\Attribute\\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);
    }
    parent::__construct([], $pluginDefinitionAttributeName);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.