You are here

public function TwigExtensionsPluginManager::__construct in Twig Extender 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/Twig/TwigExtensionsPluginManager.php \Drupal\twig_extender\Plugin\Twig\TwigExtensionsPluginManager::__construct()
  2. 8.2 src/Plugin/Twig/TwigExtensionsPluginManager.php \Drupal\twig_extender\Plugin\Twig\TwigExtensionsPluginManager::__construct()
  3. 8.3 src/Plugin/Twig/TwigExtensionsPluginManager.php \Drupal\twig_extender\Plugin\Twig\TwigExtensionsPluginManager::__construct()
  4. 4.x src/Plugin/Twig/TwigExtensionsPluginManager.php \Drupal\twig_extender\Plugin\Twig\TwigExtensionsPluginManager::__construct()

Constructs a TwigExtensionsPluginManager object.

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 $cacheBackend: Cache backend instance to use.

\Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler: The module handler to invoke the alter hook with.

\Drupal\Core\Extension\ThemeHandlerInterface $themeHandler: The theme handle to invoke the alter hook with.

Overrides DefaultPluginManager::__construct

File

src/Plugin/Twig/TwigExtensionsPluginManager.php, line 29

Class

TwigExtensionsPluginManager
Plugin type manager for all twig plugins.

Namespace

Drupal\twig_extender\Plugin\Twig

Code

public function __construct(\Traversable $namespaces, CacheBackendInterface $cacheBackend, ModuleHandlerInterface $moduleHandler, ThemeHandlerInterface $themeHandler) {
  $pluginInterface = 'Drupal\\twig_extender\\Plugin\\Twig\\TwigExtensionInterface';
  $pluginAnnotation = 'Drupal\\twig_extender\\Annotation\\TwigPlugin';
  parent::__construct("Plugin/TwigPlugin", $namespaces, $moduleHandler, $pluginInterface, $pluginAnnotation);
  $discovery = $this
    ->getDiscovery();
  $this->discovery = new YamlDiscoveryDecorator($discovery, 'twigplugins', $moduleHandler
    ->getModuleDirectories() + $themeHandler
    ->getThemeDirectories());
  $this->themeHandler = $themeHandler;
  $this->moduleHandler = $moduleHandler;
  $this
    ->setCacheBackend($cacheBackend, 'twig_extender');
  $this->defaults += array(
    'class' => 'Drupal\\twig_extender\\Plugin\\Twig\\TwigPluginBase',
  );
  $this
    ->alterInfo('twig_extender');
}