Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Block/BlockManager.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\Block; | |
4 | |
5 use Drupal\Component\Plugin\FallbackPluginManagerInterface; | |
6 use Drupal\Core\Cache\CacheBackendInterface; | |
7 use Drupal\Core\Extension\ModuleHandlerInterface; | |
8 use Drupal\Core\Plugin\CategorizingPluginManagerTrait; | |
9 use Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait; | |
10 use Drupal\Core\Plugin\DefaultPluginManager; | |
11 | |
12 /** | |
13 * Manages discovery and instantiation of block plugins. | |
14 * | |
15 * @todo Add documentation to this class. | |
16 * | |
17 * @see \Drupal\Core\Block\BlockPluginInterface | |
18 */ | |
19 class BlockManager extends DefaultPluginManager implements BlockManagerInterface, FallbackPluginManagerInterface { | |
20 | |
21 use CategorizingPluginManagerTrait { | |
22 getSortedDefinitions as traitGetSortedDefinitions; | |
23 } | |
24 use ContextAwarePluginManagerTrait; | |
25 | |
26 /** | |
27 * Constructs a new \Drupal\Core\Block\BlockManager object. | |
28 * | |
29 * @param \Traversable $namespaces | |
30 * An object that implements \Traversable which contains the root paths | |
31 * keyed by the corresponding namespace to look for plugin implementations. | |
32 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend | |
33 * Cache backend instance to use. | |
34 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler | |
35 * The module handler to invoke the alter hook with. | |
36 */ | |
37 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { | |
38 parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\Core\Block\BlockPluginInterface', 'Drupal\Core\Block\Annotation\Block'); | |
39 | |
40 $this->alterInfo('block'); | |
41 $this->setCacheBackend($cache_backend, 'block_plugins'); | |
42 } | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 public function processDefinition(&$definition, $plugin_id) { | |
48 parent::processDefinition($definition, $plugin_id); | |
49 $this->processDefinitionCategory($definition); | |
50 } | |
51 | |
52 /** | |
53 * {@inheritdoc} | |
54 */ | |
55 public function getSortedDefinitions(array $definitions = NULL) { | |
56 // Sort the plugins first by category, then by admin label. | |
57 $definitions = $this->traitGetSortedDefinitions($definitions, 'admin_label'); | |
58 // Do not display the 'broken' plugin in the UI. | |
59 unset($definitions['broken']); | |
60 return $definitions; | |
61 } | |
62 | |
63 /** | |
64 * {@inheritdoc} | |
65 */ | |
66 public function getFallbackPluginId($plugin_id, array $configuration = []) { | |
67 return 'broken'; | |
68 } | |
69 | |
70 } |