You are here

protected function TokenReplacer::getEntityFromId in Advanced Entity Tokens 2.x

Fetches an entity from its type and ID.

Parameters

string $entity_type_id: The entity type ID.

string $entity_id: The entity's ID.

Return value

EntityInterface|null

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to TokenReplacer::getEntityFromId()
TokenReplacer::getReplacementsForTokenType in src/TokenReplacer.php
Fetches token replacements for specific token types.

File

src/TokenReplacer.php, line 276

Class

TokenReplacer
Class TokenReplacer.

Namespace

Drupal\aet

Code

protected function getEntityFromId(string $entity_type_id, string $entity_id) {
  if (Uuid::isValid($entity_id)) {
    return $this->entityRepository
      ->loadEntityByUuid($entity_type_id, $entity_id);
  }
  return $this->entityTypeManager
    ->getStorage($entity_type_id)
    ->load($entity_id);
}