public static function EntityContext::fromEntity in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Plugin/Context/EntityContext.php \Drupal\Core\Plugin\Context\EntityContext::fromEntity()
- 9 core/lib/Drupal/Core/Plugin/Context/EntityContext.php \Drupal\Core\Plugin\Context\EntityContext::fromEntity()
Gets a context object from an entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Entity that provides a context.
string $label: (optional) The label of the context.
Return value
static
28 calls to EntityContext::fromEntity()
- ConditionTestDualUserTest::doTestDifferentUser in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Condition/ ConditionTestDualUserTest.php - Tests with each context mapped to different users.
- ConditionTestDualUserTest::doTestIdenticalUser in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Condition/ ConditionTestDualUserTest.php - Tests with both contexts mapped to the same user.
- ContextDefinitionTest::testIsSatisfiedBy in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ ContextDefinitionTest.php - @covers ::isSatisfiedBy
- 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/ EntityContext.php, line 56
Class
- EntityContext
- Class to provide a specific entity context.
Namespace
Drupal\Core\Plugin\ContextCode
public static function fromEntity(EntityInterface $entity, $label = NULL) {
$context = static::fromEntityType($entity
->getEntityType(), $label);
$context
->setContextValue($entity);
return $context;
}