DevelDumperPluginManager.php in Devel 8
File
src/DevelDumperPluginManager.php
View source
<?php
namespace Drupal\devel;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\devel\Annotation\DevelDumper;
class DevelDumperPluginManager extends DefaultPluginManager implements DevelDumperPluginManagerInterface {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/Devel/Dumper', $namespaces, $module_handler, DevelDumperInterface::class, DevelDumper::class);
$this
->setCacheBackend($cache_backend, 'devel_dumper_plugins');
$this
->alterInfo('devel_dumper_info');
}
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
$definition['supported'] = (bool) call_user_func([
$definition['class'],
'checkRequirements',
]);
}
public function isPluginSupported($plugin_id) {
$definition = $this
->getDefinition($plugin_id, FALSE);
return $definition && $definition['supported'];
}
public function createInstance($plugin_id, array $configuration = []) {
if (!$this
->isPluginSupported($plugin_id)) {
$plugin_id = $this
->getFallbackPluginId($plugin_id);
}
return parent::createInstance($plugin_id, $configuration);
}
public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'default';
}
}