You are here

public static function EntityContext::fromEntityTypeId in Drupal 10

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

Gets a context from an entity type ID.

Parameters

string $entity_type_id: Entity type ID from which a definition will be derived.

string $label: (optional) The label of the context.

Return value

static

3 calls to EntityContext::fromEntityTypeId()
CurrentUserContext::getRuntimeContexts in core/modules/user/src/ContextProvider/CurrentUserContext.php
Gets runtime context values for the given context IDs.
NodeRouteContext::getAvailableContexts in core/modules/node/src/ContextProvider/NodeRouteContext.php
Gets all available contexts for the purposes of configuration.
TermRouteContext::getAvailableContexts in core/modules/taxonomy/src/ContextProvider/TermRouteContext.php
Gets all available contexts for the purposes of configuration.

File

core/lib/Drupal/Core/Plugin/Context/EntityContext.php, line 23

Class

EntityContext
Class to provide a specific entity context.

Namespace

Drupal\Core\Plugin\Context

Code

public static function fromEntityTypeId($entity_type_id, $label = NULL) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($entity_type_id);
  return static::fromEntityType($entity_type, $label);
}