You are here

public function KeyPluginManager::__construct in Key 8

Constructs a KeyPluginManager.

Parameters

string $type: The plugin type.

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

\Drupal\Core\Cache\CacheBackendInterface $cache_backend: Cache backend instance to use.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler.

Overrides DefaultPluginManager::__construct

File

src/Plugin/KeyPluginManager.php, line 34

Class

KeyPluginManager
Manages Key plugins.

Namespace

Drupal\key\Plugin

Code

public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
  $type_annotations = [
    'key_type' => 'Drupal\\key\\Annotation\\KeyType',
    'key_provider' => 'Drupal\\key\\Annotation\\KeyProvider',
    'key_input' => 'Drupal\\key\\Annotation\\KeyInput',
  ];
  $plugin_interfaces = [
    'key_type' => 'Drupal\\key\\Plugin\\KeyTypeInterface',
    'key_provider' => 'Drupal\\key\\Plugin\\KeyProviderInterface',
    'key_input' => 'Drupal\\key\\Plugin\\KeyInputInterface',
  ];
  $this->pluginType = $type;
  $this->subdir = 'Plugin/' . str_replace(' ', '', ucwords(str_replace('_', ' ', $type)));
  parent::__construct($this->subdir, $namespaces, $module_handler, $plugin_interfaces[$type], $type_annotations[$type]);
  $this
    ->alterInfo($type . '_info');
  $this
    ->setCacheBackend($cache_backend, $type, [
    'key_plugins',
  ]);
}