You are here

public function EntityExtraField::getBaseEntityContext in Entity Extra Field 2.0.x

Get the base entity context.

Return value

\Drupal\Core\Plugin\Context\EntityContext The entity context.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

Overrides EntityExtraFieldInterface::getBaseEntityContext

File

src/Entity/EntityExtraField.php, line 247

Class

EntityExtraField
Define entity extra field.

Namespace

Drupal\entity_extra_field\Entity

Code

public function getBaseEntityContext() : EntityContext {
  $definition = $this
    ->getBaseEntityType();
  $label = $this
    ->t('@entity being viewed', [
    '@entity' => $definition
      ->getLabel(),
  ]);
  $entity_context = EntityContext::fromEntityType($definition, $label);
  $context_definition = $entity_context
    ->getContextDefinition();
  $context_definition
    ->addConstraint('Bundle', [
    $this
      ->getBaseBundleTypeId(),
  ]);
  return $entity_context;
}