You are here

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

Fetches an entire entity for insertion (e.g. "[aet:node:999]").

Parameters

string $entity_type_id: The entity type ID.

EntityInterface $entity: The entity.

array $tokens: The list of tokens.

Return value

array The list of replacements, with the entire entity included if available.

1 call to TokenReplacer::getWholeEntityReplacements()
TokenReplacer::getReplacementsForEntity in src/TokenReplacer.php
Fetches token replacements for a specific entity.

File

src/TokenReplacer.php, line 453

Class

TokenReplacer
Class TokenReplacer.

Namespace

Drupal\aet

Code

protected function getWholeEntityReplacements(string $entity_type_id, EntityInterface $entity, array $tokens) {
  $replacements = [];
  if (isset($tokens[$entity
    ->id()]) || isset($tokens[$entity
    ->uuid()])) {
    $view_mode = isset($this->entityDisplayRepository
      ->getViewModes($entity_type_id)['token']) ? 'token' : 'full';
    $id = isset($tokens[$entity
      ->id()]) ? $entity
      ->id() : $entity
      ->uuid();
    $replacements[$tokens[$id]] = $this
      ->getRenderedEntity($entity_type_id, $entity, $view_mode);
  }
  return $replacements;
}