You are here

public static function EntityContextDefinition::fromEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::fromEntity()
  2. 9 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::fromEntity()

Creates a context definition from a given entity object.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity from which to derive a context definition.

Return value

static

2 calls to EntityContextDefinition::fromEntity()
ContextHandlerTest::testApplyContextMapping in core/tests/Drupal/KernelTests/Core/Plugin/ContextHandlerTest.php
@covers ::applyContextMapping
ContextHandlerTest::testApplyContextMappingAlreadyApplied in core/tests/Drupal/KernelTests/Core/Plugin/ContextHandlerTest.php
@covers ::applyContextMapping

File

core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php, line 112

Class

EntityContextDefinition
Defines a class to provide entity context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

public static function fromEntity(EntityInterface $entity) {
  return static::fromEntityType($entity
    ->getEntityType());
}