function public function PluginManager::__construct

8.x-3.x PluginManager.php public PluginManager::__construct(Theme $theme, $subdir, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin')

Creates the discovery object.

Parameters

\Drupal\bootstrap\Theme $theme: The theme to use for discovery.

string|bool $subdir: The plugin's subdirectory, for example Plugin/views/filter.

string|null $plugin_interface: (optional) The interface each plugin should implement.

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

Class

PluginManager
Base class for Bootstrap plugin managers.

Namespace

Drupal\bootstrap\Plugin

Source src/Plugin/PluginManager.php (line 50)

public function __construct(Theme $theme, $subdir, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') {
  // Get the active theme.
  $this->theme = $theme;

  // Determine the namespaces to search for.
  $namespaces = [];
  foreach ($theme->getAncestry() as $ancestor) {
    $namespaces['Drupal\\' . $ancestor->getName()] = [DRUPAL_ROOT . '/' . $ancestor->getPath() . '/src'];
  }
  $this->namespaces = new \ArrayObject($namespaces);

  $this->subdir = $subdir;
  $this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
  $this->pluginInterface = $plugin_interface;
  $this->themeHandler = \Drupal::service('theme_handler');
  $this->themeManager = \Drupal::service('theme.manager');
}