You are here

public static function EntityContext::fromEntityType in Drupal 8

Same name and namespace in other branches
  1. 9 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\Context

Code

public static function fromEntityType(EntityTypeInterface $entity_type, $label = NULL) {
  $definition = EntityContextDefinition::fromEntityType($entity_type);
  if ($label) {
    $definition
      ->setLabel($label);
  }
  return new static($definition);
}