You are here

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

Fetches entity type information based on the type of token.

Parameters

string $token_type: The token type.

Return value

array The first item is the entity type ID, and the second one is the entity type instance, Drupal\Core\Entity\EntityType.

2 calls to TokenReplacer::getEntityInfoMatchingTokenType()
TokenReplacer::getEntityViewReplacements in src/TokenReplacer.php
Fetches the entity view replacements.
TokenReplacer::getReplacementsForTokenType in src/TokenReplacer.php
Fetches token replacements for specific token types.

File

src/TokenReplacer.php, line 552

Class

TokenReplacer
Class TokenReplacer.

Namespace

Drupal\aet

Code

protected function getEntityInfoMatchingTokenType(string $token_type) {
  $entity_type_id = '';
  $entity_type_info = NULL;
  foreach ($this->entityTypeManager
    ->getDefinitions() as $key => $value) {
    $entity_token_type = $value
      ->get('additional')['token_type'] ?: NULL;
    if ($entity_token_type === $token_type) {
      $entity_type_id = $key;
      $entity_type_info = $value;
      break;
    }
  }
  return [
    $entity_type_id,
    $entity_type_info,
  ];
}