function EntityContextDefinition::fromEntity

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::fromEntity()
  2. 8.9.x core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::fromEntity()
  3. 10 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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.