BootstrapLayoutsPluginManager.php in Bootstrap Layouts 8.5
File
src/BootstrapLayoutsPluginManager.php
View source
<?php
namespace Drupal\bootstrap_layouts;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Theme\ThemeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BootstrapLayoutsPluginManager extends DefaultPluginManager implements ContainerInjectionInterface, ContainerAwareInterface {
use ContainerAwareTrait;
use StringTranslationTrait;
protected $themeHandler;
protected $themeManager;
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, ThemeManagerInterface $theme_manager, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin') {
$class_loader = \Drupal::service('class_loader');
$ns = $namespaces
->getArrayCopy();
foreach ($class_loader
->getPrefixesPsr4() as $prefix => $paths) {
$prefix = trim($prefix, '\\');
$path = str_replace(\Drupal::root() . '/', '', reset($paths));
if (preg_match('/^(core|vendor)/', $path) === 0 && !isset($namespaces[$prefix])) {
$ns[$prefix] = $path;
}
}
$namespaces
->exchangeArray($ns);
parent::__construct('Plugin/BootstrapLayouts', $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);
$this->themeHandler = $theme_handler;
$this->themeManager = $theme_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('container.namespaces'), $container
->get('cache.discovery'), $container
->get('module_handler'), $container
->get('theme_handler'), $container
->get('theme.manager'));
}
protected function alterDefinitions(&$definitions) {
if ($this->alterHook) {
$this->moduleHandler
->alter($this->alterHook, $definitions);
$this->themeManager
->alter($this->alterHook, $definitions);
}
}
protected function providerExists($provider) {
return $this->moduleHandler
->moduleExists($provider) || $this->themeHandler
->themeExists($provider);
}
}