diff -u b/src/Plugin/BlockVariantTrait.php b/src/Plugin/BlockVariantTrait.php --- b/src/Plugin/BlockVariantTrait.php +++ b/src/Plugin/BlockVariantTrait.php @@ -51,6 +51,7 @@ $this->getBlockCollection()->addInstanceId($configuration['uuid'], $configuration); $block = $this->getBlock($configuration['uuid']); + // Allow modules to react to the change. $event = new BlockVariantEvent($block, $this); $this->eventDispatcher()->dispatch(BlockVariantEvents::ADD_BLOCK, $event); @@ -62,9 +63,12 @@ */ public function removeBlock($block_id) { $block = $this->getBlock($block_id); + $this->getBlockCollection()->removeInstanceId($block_id); + + // Allow modules to react to the change. $event = new BlockVariantEvent($block, $this); $this->eventDispatcher()->dispatch(BlockVariantEvents::DELETE_BLOCK, $event); - $this->getBlockCollection()->removeInstanceId($block_id); + return $this; } @@ -75,8 +79,11 @@ $block = $this->getBlock($block_id); $existing_configuration = $block->getConfiguration(); $this->getBlockCollection()->setInstanceConfiguration($block_id, $configuration + $existing_configuration); + + // Allow modules to react to the change. $event = new BlockVariantEvent($block, $this); $this->eventDispatcher()->dispatch(BlockVariantEvents::UPDATE_BLOCK, $event); + return $this; }