BlockStyleManager.php in Block Style Plugins 8
File
src/Plugin/BlockStyleManager.php
View source
<?php
namespace Drupal\block_style_plugins\Plugin;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Plugin\Discovery\YamlDiscoveryDecorator;
class BlockStyleManager extends DefaultPluginManager {
protected $defaults = [
'class' => 'Drupal\\block_style_plugins\\Plugin\\BlockStyle',
];
protected $themeHandler;
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
parent::__construct('Plugin/BlockStyle', $namespaces, $module_handler, 'Drupal\\block_style_plugins\\Plugin\\BlockStyleInterface', 'Drupal\\block_style_plugins\\Annotation\\BlockStyle');
$discovery = $this
->getDiscovery();
$this->discovery = new YamlDiscoveryDecorator($discovery, 'blockstyle', $module_handler
->getModuleDirectories() + $theme_handler
->getThemeDirectories());
$this->themeHandler = $theme_handler;
$this
->alterInfo('block_style_plugins_info');
$this
->setCacheBackend($cache_backend, 'block_style_plugins');
}
protected function providerExists($provider) {
return $this->moduleHandler
->moduleExists($provider) || $this->themeHandler
->themeExists($provider);
}
}