You are here

public function DefaultPluginManager::__construct in Plug 7

Creates the discovery object.

Parameters

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

\Traversable $namespaces: An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations.

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

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

2 calls to DefaultPluginManager::__construct()
FruitPluginManager::__construct in modules/plug_example/src/FruitPluginManager.php
Constructs FruitPluginManager.
NamePluginManager::__construct in modules/plug_example/src/NamePluginManager.php
Constructs NamePluginManager.
2 methods override DefaultPluginManager::__construct()
FruitPluginManager::__construct in modules/plug_example/src/FruitPluginManager.php
Constructs FruitPluginManager.
NamePluginManager::__construct in modules/plug_example/src/NamePluginManager.php
Constructs NamePluginManager.

File

lib/Drupal/Core/Plugin/DefaultPluginManager.php, line 110
Contains \Drupal\Core\Plugin\DefaultPluginManager.

Class

DefaultPluginManager
Base class for plugin managers.

Namespace

Drupal\Core\Plugin

Code

public function __construct($subdir, \Traversable $namespaces, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin') {
  $this->subdir = $subdir;
  $this->namespaces = $namespaces;
  $this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
  $this->pluginInterface = $plugin_interface;

  // Add the file cache prefix.
  $configuration['default'] = [
    'class' => '\\Drupal\\Component\\FileCache\\FileCache',
    'cache_backend_class' => NULL,
    'cache_backend_configuration' => [],
  ];

  // @todo Use extension_loaded('apcu') for non-testbot
  //  https://www.drupal.org/node/2447753.
  if (function_exists('apc_fetch')) {
    $configuration['default']['cache_backend_class'] = '\\Drupal\\Component\\FileCache\\ApcuFileCacheBackend';
  }
  FileCacheFactory::setConfiguration($configuration);
  $identifier = 'file_cache';
  FileCacheFactory::setPrefix('drupal.' . $identifier . '.' . hash_hmac('sha256', $identifier, drupal_get_hash_salt()));
}