You are here

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

Fetches token replacements for a specific entity.

Parameters

string $entity_type_id: The entity type ID.

\Drupal\Core\Entity\EntityInterface $entity: The entity.

string $token_type: The token type.

array $tokens: The tokens.

Return value

array The replacements.

Throws

\Exception

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

File

src/TokenReplacer.php, line 430

Class

TokenReplacer
Class TokenReplacer.

Namespace

Drupal\aet

Code

protected function getReplacementsForEntity(string $entity_type_id, EntityInterface $entity, string $token_type, array $tokens) : array {
  if (!$entity
    ->access('view', $this->currentUser)) {
    return [];
  }
  $replacements = $this
    ->getWholeEntityReplacements($entity_type_id, $entity, $tokens);
  $replacements += $this
    ->getEntityAttributeReplacements($entity, $token_type, $tokens);
  return $replacements;
}