diff --git a/core/includes/language.inc b/core/includes/language.inc index 74cc832..a75bfdc 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -211,10 +211,10 @@ function language_types_disable($types) { foreach ($types as $type) { unset($enabled_types[$type]); - // Inform the block plugin system you have removed a language. - if (\Drupal::moduleHandler()->moduleExists('block')) { + // Inform the block plugin system that a language has been deleted. + if (Drupal::moduleHandler()->moduleExists('block')) { $event = new GenericEvent('language_block:' . $type); - \Drupal::service('event_dispatcher')->dispatch(BlockPluginEvents::PERMANENTLY_UNAVAILABLE, $event); + Drupal::service('event_dispatcher')->dispatch(BlockPluginEvents::TEMPORARILY_UNAVAILABLE, $event); } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php index 8e98587..a212ac6 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php @@ -229,7 +229,7 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr */ public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) { foreach ($entities as $entity) { - // Inform the block plugin system you have deleted a feed. + // Inform the block plugin system that a feed has been deleted. if (\Drupal::moduleHandler()->moduleExists('block')) { $event = new GenericEvent('aggregator_feed_block:' . $entity->id()); \Drupal::service('event_dispatcher')->dispatch(BlockPluginEvents::PERMANENTLY_UNAVAILABLE, $event); diff --git a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php index 3d2453f..1887816 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php @@ -102,6 +102,4 @@ public function submit($form, &$form_state); */ public function build(); - - } diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index 6a351f2..e58576a 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -52,6 +52,9 @@ public static function getSubscribedEvents() { /** * Reacts on removing a block plugin. + * + * @param \Symfony\Component\EventDispatcher\GenericEvent $event + * The event containing the plugin ID which is updated. */ public function blockPluginRemoved(GenericEvent $event) { $this->clearCachedDefinitions(); diff --git a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php index 8b31cbe..0adb514 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/views/display/Block.php @@ -12,7 +12,10 @@ use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; use Drupal\views\Plugin\views\display\DisplayPluginBase; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; /** @@ -40,6 +43,13 @@ class Block extends DisplayPluginBase { */ protected $usesAttachments = TRUE; + /** + * The event dispatcher. + * + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ + protected $eventDispatcher; + protected function defineOptions() { $options = parent::defineOptions(); @@ -50,6 +60,35 @@ protected function defineOptions() { } /** + * Constructs a Block object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EventDispatcherInterface $event_dispatcher) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->eventDispatcher = $event_dispatcher; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('event_dispatcher') + ); + } + + /** * The display block handler returns the structure necessary for a block. */ public function execute() { @@ -188,14 +227,14 @@ public function usesExposed() { } /** - * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::remove(). + * {@inheritdoc} */ public function remove() { parent::remove(); $plugin_id = 'views_block:' . $this->view->storage->id() . '-' . $this->display['id']; $event = new GenericEvent($plugin_id); - \Drupal::service('event_dispatcher')->dispatch(BlockPluginEvents::PERMANENTLY_UNAVAILABLE, $event); + $this->eventDispatcher->dispatch(BlockPluginEvents::PERMANENTLY_UNAVAILABLE, $event); } } diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 8b62f0a..2006902 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -306,9 +306,10 @@ function menu_menu_delete(Menu $menu) { menu_cache_clear_all(); // Inform the block plugin system you have deleted a menu. + // Inform the block plugin system that a menu has been deleted. if (Drupal::moduleHandler()->moduleExists('block')) { $event = new GenericEvent('menu_menu_block:' . $menu->id()); - \Drupal::service('event_dispatcher')->dispatch(BlockPluginEvents::PERMANENTLY_UNAVAILABLE, $event); + Drupal::service('event_dispatcher')->dispatch(BlockPluginEvents::PERMANENTLY_UNAVAILABLE, $event); } }