You are here

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

Fetches replacements for entity attributes (e.g. "[aet:node:999:changed]").

Parameters

EntityInterface $entity: The entity.

string $token_type: The token type.

array $tokens: The list of tokens.

Return value

array

Throws

\Exception

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

File

src/TokenReplacer.php, line 477

Class

TokenReplacer
Class TokenReplacer.

Namespace

Drupal\aet

Code

protected function getEntityAttributeReplacements(EntityInterface $entity, string $token_type, array $tokens) {
  $replacements = [];
  $entity_tokens = $this->tokenService
    ->findWithPrefix($tokens, $entity
    ->id());
  $entity_tokens += $this->tokenService
    ->findWithPrefix($tokens, $entity
    ->uuid());
  $data = [
    $token_type => $entity,
  ];
  $replacements += $this
    ->getEntityViewReplacements($token_type, $entity_tokens, $data);

  // For the remainder, after the entity type and ID have been figured out.
  $replacements += $this->tokenService
    ->generate($token_type, $entity_tokens, $data, $this
    ->getOptions(), $this
    ->getBubbleableMetadata());
  return $replacements;
}