public function BootstrapLayoutsPluginManager::__construct in Bootstrap Layouts 8.5
Same name and namespace in other branches
- 8.4 src/BootstrapLayoutsPluginManager.php \Drupal\bootstrap_layouts\BootstrapLayoutsPluginManager::__construct()
Base plugin manager for Bootstrap Layouts plugin managers.
The "container.namespaces" service does not contain theme namespaces since themes are not registered in the container. To allow themes to be able to participate in these plugins, the normal "namespaces" provided must be appending with the missing autoloader prefixes of the themes.
Parameters
\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 to invoke the alter hook with.
\Drupal\Core\Extension\ThemeHandlerInterface $theme_handler: The theme manager used to invoke the alter hook with.
\Drupal\Core\Theme\ThemeManagerInterface $theme_manager: The theme manager used to invoke the alter hook with.
string|null $plugin_interface: (optional) The interface each plugin should implement.
string $plugin_definition_annotation_name: (optional) The name of the annotation that contains the plugin definition. Defaults to 'Drupal\Component\Annotation\Plugin'.
Overrides DefaultPluginManager::__construct
2 calls to BootstrapLayoutsPluginManager::__construct()
- BootstrapLayoutsManager::__construct in src/
BootstrapLayoutsManager.php - Constructs a new \Drupal\bootstrap_layouts\BootstrapLayoutsManager object.
- BootstrapLayoutsUpdateManager::__construct in src/
BootstrapLayoutsUpdateManager.php - Constructs a new \Drupal\bootstrap_layouts\BootstrapLayoutsManager object.
2 methods override BootstrapLayoutsPluginManager::__construct()
- BootstrapLayoutsManager::__construct in src/
BootstrapLayoutsManager.php - Constructs a new \Drupal\bootstrap_layouts\BootstrapLayoutsManager object.
- BootstrapLayoutsUpdateManager::__construct in src/
BootstrapLayoutsUpdateManager.php - Constructs a new \Drupal\bootstrap_layouts\BootstrapLayoutsManager object.
File
- src/
BootstrapLayoutsPluginManager.php, line 56
Class
Namespace
Drupal\bootstrap_layoutsCode
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') {
/** @var \Composer\Autoload\ClassLoader $class_loader */
$class_loader = \Drupal::service('class_loader');
/** @var \ArrayObject $namespaces */
$ns = $namespaces
->getArrayCopy();
foreach ($class_loader
->getPrefixesPsr4() as $prefix => $paths) {
// Remove trailing path separators.
$prefix = trim($prefix, '\\');
// Remove the DRUPAL_ROOT prefix.
$path = str_replace(\Drupal::root() . '/', '', reset($paths));
// Only add missing contrib theme namespaces.
if (preg_match('/^(core|vendor)/', $path) === 0 && !isset($namespaces[$prefix])) {
$ns[$prefix] = $path;
}
}
// Replace the namespaces data.
$namespaces
->exchangeArray($ns);
// Construct the plugin manager now.
parent::__construct('Plugin/BootstrapLayouts', $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);
// Set the theme handler and manager.
$this->themeHandler = $theme_handler;
$this->themeManager = $theme_manager;
}