You are here

public function EntityEmbedDisplayBase::getEntityFromContext in Entity Embed 8

Gets the entity from the current context.

@todo Where does this come from? The value must come from somewhere, yet this does not implement any context-related interfaces. This is an *input*, so we need cache contexts and possibly cache tags to reflect where this came from. We need that for *everything* that this class does that relies on this, plus any of its subclasses. Right now, this is effectively a global that breaks cacheability metadata.

Return value

\Drupal\Core\Entity\EntityInterface The entity from the current context.

2 calls to EntityEmbedDisplayBase::getEntityFromContext()
EntityReferenceFieldFormatter::build in src/Plugin/entity_embed/EntityEmbedDisplay/EntityReferenceFieldFormatter.php
Builds the renderable array for this Entity Embed display plugin.
ImageFieldFormatter::isValidImage in src/Plugin/entity_embed/EntityEmbedDisplay/ImageFieldFormatter.php
Checks if the image is valid.

File

src/EntityEmbedDisplay/EntityEmbedDisplayBase.php, line 284

Class

EntityEmbedDisplayBase
Defines a base Entity Embed Display implementation.

Namespace

Drupal\entity_embed\EntityEmbedDisplay

Code

public function getEntityFromContext() {
  if ($this
    ->hasContextValue('entity')) {
    return $this
      ->getContextValue('entity');
  }
}