<?php
/**
* Contains \Drupal\block\Plugin\Type\BlockManager.
*/
namespace Drupal\block\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Component\Plugin\Factory\DefaultFactory;
/**
* Manages discovery and instantiation of block plugins.
*
* @todo Add documentation to this class.
*
* @see \Drupal\block\BlockPluginInterface
*/
class BlockManager extends PluginManagerBase {
/**
* Constructs a new \Drupal\block\Plugin\Type\BlockManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('Block', $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'block');
$this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(Language::TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array(
'block',
));
$this->factory = new DefaultFactory($this->discovery);
}
}
Name | Description |
---|---|
BlockManager | Manages discovery and instantiation of block plugins. |