public function ReusableBlockProcessor::processBlock in Gutenberg 8.2
Process the Gutenberg block and its content.
The content and block can be manipulated here. Return FALSE to ensure that no other plugins are ran after this instance.
Parameters
array $block: The block object.
string $block_content: The inner block content.
\Drupal\Core\Cache\RefinableCacheableDependencyInterface $bubbleable_metadata: The bubbleable metadata.
Return value
bool|null Return FALSE if further processing should be stopped.
Overrides GutenbergBlockProcessorInterface::processBlock
File
- src/
BlockProcessor/ ReusableBlockProcessor.php, line 61
Class
- ReusableBlockProcessor
- Processes Gutenberg reusable blocks.
Namespace
Drupal\gutenberg\BlockProcessorCode
public function processBlock(array &$block, &$block_content, RefinableCacheableDependencyInterface $bubbleable_metadata) {
$block_attributes = $block['attrs'];
if (empty($block_attributes['ref'])) {
// This should not happen, and typically means there's a bug somewhere.
$this->logger
->error('Missing reusable block reference ID.');
return;
}
$bid = $block_attributes['ref'];
$block_entity = BlockContent::load($bid);
if ($block_entity) {
$render = $this->entityTypeManager
->getViewBuilder('block_content')
->view($block_entity, 'reusable_block');
$block_content = $this->renderer
->render($render);
$bubbleable_metadata
->addCacheableDependency(CacheableMetadata::createFromRenderArray($render));
}
}