function EntityContext::fromEntityType
Same name in other branches
- 9 core/lib/Drupal/Core/Plugin/Context/EntityContext.php \Drupal\Core\Plugin\Context\EntityContext::fromEntityType()
- 8.9.x core/lib/Drupal/Core/Plugin/Context/EntityContext.php \Drupal\Core\Plugin\Context\EntityContext::fromEntityType()
- 11.x core/lib/Drupal/Core/Plugin/Context/EntityContext.php \Drupal\Core\Plugin\Context\EntityContext::fromEntityType()
Gets a context from an entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: Entity type from which a definition will be derived.
string $label: (optional) The label of the context.
Return value
static
2 calls to EntityContext::fromEntityType()
- EntityContext::fromEntity in core/
lib/ Drupal/ Core/ Plugin/ Context/ EntityContext.php - Gets a context object from an entity.
- EntityContext::fromEntityTypeId in core/
lib/ Drupal/ Core/ Plugin/ Context/ EntityContext.php - Gets a context from an entity type ID.
File
-
core/
lib/ Drupal/ Core/ Plugin/ Context/ EntityContext.php, line 38
Class
- EntityContext
- Class to provide a specific entity context.
Namespace
Drupal\Core\Plugin\ContextCode
public static function fromEntityType(EntityTypeInterface $entity_type, $label = NULL) {
$definition = EntityContextDefinition::fromEntityType($entity_type);
if ($label) {
$definition->setLabel($label);
}
return new static($definition);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.