comparison core/lib/Drupal/Core/Block/BlockManager.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
4 4
5 use Drupal\Component\Plugin\FallbackPluginManagerInterface; 5 use Drupal\Component\Plugin\FallbackPluginManagerInterface;
6 use Drupal\Core\Cache\CacheBackendInterface; 6 use Drupal\Core\Cache\CacheBackendInterface;
7 use Drupal\Core\Extension\ModuleHandlerInterface; 7 use Drupal\Core\Extension\ModuleHandlerInterface;
8 use Drupal\Core\Plugin\CategorizingPluginManagerTrait; 8 use Drupal\Core\Plugin\CategorizingPluginManagerTrait;
9 use Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait;
10 use Drupal\Core\Plugin\DefaultPluginManager; 9 use Drupal\Core\Plugin\DefaultPluginManager;
10 use Drupal\Core\Plugin\FilteredPluginManagerTrait;
11 use Psr\Log\LoggerInterface;
11 12
12 /** 13 /**
13 * Manages discovery and instantiation of block plugins. 14 * Manages discovery and instantiation of block plugins.
14 * 15 *
15 * @todo Add documentation to this class. 16 * @todo Add documentation to this class.
19 class BlockManager extends DefaultPluginManager implements BlockManagerInterface, FallbackPluginManagerInterface { 20 class BlockManager extends DefaultPluginManager implements BlockManagerInterface, FallbackPluginManagerInterface {
20 21
21 use CategorizingPluginManagerTrait { 22 use CategorizingPluginManagerTrait {
22 getSortedDefinitions as traitGetSortedDefinitions; 23 getSortedDefinitions as traitGetSortedDefinitions;
23 } 24 }
24 use ContextAwarePluginManagerTrait; 25 use FilteredPluginManagerTrait;
26
27 /**
28 * The logger.
29 *
30 * @var \Psr\Log\LoggerInterface
31 */
32 protected $logger;
25 33
26 /** 34 /**
27 * Constructs a new \Drupal\Core\Block\BlockManager object. 35 * Constructs a new \Drupal\Core\Block\BlockManager object.
28 * 36 *
29 * @param \Traversable $namespaces 37 * @param \Traversable $namespaces
31 * keyed by the corresponding namespace to look for plugin implementations. 39 * keyed by the corresponding namespace to look for plugin implementations.
32 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend 40 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
33 * Cache backend instance to use. 41 * Cache backend instance to use.
34 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler 42 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
35 * The module handler to invoke the alter hook with. 43 * The module handler to invoke the alter hook with.
44 * @param \Psr\Log\LoggerInterface $logger
45 * The logger.
36 */ 46 */
37 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { 47 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LoggerInterface $logger) {
38 parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\Core\Block\BlockPluginInterface', 'Drupal\Core\Block\Annotation\Block'); 48 parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\Core\Block\BlockPluginInterface', 'Drupal\Core\Block\Annotation\Block');
39 49
40 $this->alterInfo('block'); 50 $this->alterInfo($this->getType());
41 $this->setCacheBackend($cache_backend, 'block_plugins'); 51 $this->setCacheBackend($cache_backend, 'block_plugins');
52 $this->logger = $logger;
53 }
54
55 /**
56 * {@inheritdoc}
57 */
58 protected function getType() {
59 return 'block';
42 } 60 }
43 61
44 /** 62 /**
45 * {@inheritdoc} 63 * {@inheritdoc}
46 */ 64 */
65 */ 83 */
66 public function getFallbackPluginId($plugin_id, array $configuration = []) { 84 public function getFallbackPluginId($plugin_id, array $configuration = []) {
67 return 'broken'; 85 return 'broken';
68 } 86 }
69 87
88 /**
89 * {@inheritdoc}
90 */
91 protected function handlePluginNotFound($plugin_id, array $configuration) {
92 $this->logger->warning('The "%plugin_id" was not found', ['%plugin_id' => $plugin_id]);
93 return parent::handlePluginNotFound($plugin_id, $configuration);
94 }
95
70 } 96 }