public function BlockVariantTrait::addBlock in Chaos Tool Suite (ctools) 8.3
See also
\Drupal\ctools\Plugin\BlockVariantInterface::addBlock()
File
- src/
Plugin/ BlockVariantTrait.php, line 49
Class
- BlockVariantTrait
- Provides methods for \Drupal\ctools\Plugin\BlockVariantInterface.
Namespace
Drupal\ctools\PluginCode
public function addBlock(array $configuration) {
$configuration['uuid'] = $this
->uuidGenerator()
->generate();
$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);
return $configuration['uuid'];
}