function BlockVariantTrait::updateBlock

Same name in other branches
  1. 8.x-3.x src/Plugin/BlockVariantTrait.php \Drupal\ctools\Plugin\BlockVariantTrait::updateBlock()

See also

\Drupal\ctools\Plugin\BlockVariantInterface::updateBlock()

File

src/Plugin/BlockVariantTrait.php, line 78

Class

BlockVariantTrait
Provides methods for \Drupal\ctools\Plugin\BlockVariantInterface.

Namespace

Drupal\ctools\Plugin

Code

public function updateBlock($block_id, array $configuration) {
    $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($event, BlockVariantEvents::UPDATE_BLOCK);
    return $this;
}