diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php index d8b0fd9..8de34dd 100644 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -116,6 +116,13 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin protected $conditionPluginManager; /** + * This block wrapped in a context object. + * + * @var \Drupal\Core\Plugin\Context\Context + */ + protected $blockContext; + + /** * {@inheritdoc} */ public function getPlugin() { @@ -221,8 +228,11 @@ public function getCacheTags() { * {@inheritdoc} */ public function setContexts(array $contexts) { - $contexts['block'] = new Context(new ContextDefinition('entity:block')); - $contexts['block']->setContextValue($this); + if (!isset($this->blockContext)) { + $this->blockContext = new Context(new ContextDefinition('entity:block')); + $this->blockContext->setContextValue($this); + } + $contexts['block.block_entity'] = $this->blockContext; $this->contexts = $contexts; return $this; }