Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / src / Plugin / views / display / Block.php
index 5e833d752a5776d7377c6ba7357148ae81397176..e210ee3231ab32ef941df9d39cfdbee11936440c 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Drupal\views\Plugin\views\display;
 
+use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
+use Drupal\Core\Block\BlockManagerInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\Block\ViewsBlock;
@@ -42,6 +44,13 @@ class Block extends DisplayPluginBase {
    */
   protected $entityManager;
 
+  /**
+   * The block manager.
+   *
+   * @var \Drupal\Core\Block\BlockManagerInterface
+   */
+  protected $blockManager;
+
   /**
    * Constructs a new Block instance.
    *
@@ -53,11 +62,14 @@ class Block extends DisplayPluginBase {
    *   The plugin implementation definition.
    * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    *   The entity manager.
+   * @param \Drupal\Core\Block\BlockManagerInterface $block_manager
+   *   The block manager.
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, BlockManagerInterface $block_manager) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
 
     $this->entityManager = $entity_manager;
+    $this->blockManager = $block_manager;
   }
 
   /**
@@ -68,7 +80,8 @@ class Block extends DisplayPluginBase {
       $configuration,
       $plugin_id,
       $plugin_definition,
-      $container->get('entity.manager')
+      $container->get('entity.manager'),
+      $container->get('plugin.manager.block')
     );
   }
 
@@ -364,6 +377,9 @@ class Block extends DisplayPluginBase {
         $block->delete();
       }
     }
+    if ($this->blockManager instanceof CachedDiscoveryInterface) {
+      $this->blockManager->clearCachedDefinitions();
+    }
   }
 
 }