protected function BlocksRendererHelper::addCacheTagsToRender in Gutenberg 8
Same name and namespace in other branches
- 8.2 src/BlocksRendererHelper.php \Drupal\gutenberg\BlocksRendererHelper::addCacheTagsToRender()
Add default cache tags for empty block.
Parameters
array $render: Render array.
array $content: Block build content.
1 call to BlocksRendererHelper::addCacheTagsToRender()
- BlocksRendererHelper::getRenderFromBlockPlugin in src/
BlocksRendererHelper.php - Return render array for given block plugin.
File
- src/
BlocksRendererHelper.php, line 154
Class
- BlocksRendererHelper
- Class BlocksRendererHelper.
Namespace
Drupal\gutenbergCode
protected function addCacheTagsToRender(array &$render, array $content) {
// If the block is empty, instead of trying to render the block
// correctly return just #cache, so that the render system knows the
// reasons (cache contexts & tags) why this block is empty.
if (Element::isEmpty($content)) {
$cacheableMetadata = CacheableMetadata::createFromObject($render);
$cacheableMetadata
->applyTo($render);
if (isset($content['#cache'])) {
$render['#cache'] += $content['#cache'];
}
}
}