3 namespace Drupal\devel;
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Plugin\DefaultPluginManager;
8 use Drupal\devel\Annotation\DevelDumper;
11 * Plugin type manager for Devel Dumper plugins.
13 * @see \Drupal\devel\Annotation\DevelDumper
14 * @see \Drupal\devel\DevelDumperInterface
15 * @see \Drupal\devel\DevelDumperBase
18 class DevelDumperPluginManager extends DefaultPluginManager implements DevelDumperPluginManagerInterface {
21 * Constructs a DevelDumperPluginManager object.
23 * @param \Traversable $namespaces
24 * An object that implements \Traversable which contains the root paths
25 * keyed by the corresponding namespace to look for plugin implementations.
26 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
27 * Cache backend instance to use.
28 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
29 * The module handler to invoke the alter hook with.
31 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
32 parent::__construct('Plugin/Devel/Dumper', $namespaces, $module_handler, DevelDumperInterface::class, DevelDumper::class);
33 $this->setCacheBackend($cache_backend, 'devel_dumper_plugins');
34 $this->alterInfo('devel_dumper_info');
40 public function processDefinition(&$definition, $plugin_id) {
41 parent::processDefinition($definition, $plugin_id);
43 $definition['supported'] = (bool) call_user_func([$definition['class'], 'checkRequirements']);
49 public function isPluginSupported($plugin_id) {
50 $definition = $this->getDefinition($plugin_id, FALSE);
51 return $definition && $definition['supported'];
57 public function createInstance($plugin_id, array $configuration = []) {
58 if (!$this->isPluginSupported($plugin_id)) {
59 $plugin_id = $this->getFallbackPluginId($plugin_id);
61 return parent::createInstance($plugin_id, $configuration);
67 public function getFallbackPluginId($plugin_id, array $configuration = []) {