KeyPluginManager.php in Key 8
File
src/Plugin/KeyPluginManager.php
View source
<?php
namespace Drupal\key\Plugin;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class KeyPluginManager extends DefaultPluginManager {
protected $pluginType;
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',
]);
}
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
$definition['plugin_type'] = $this->pluginType;
}
}