public function TokenReplacer::getReplacements in Advanced Entity Tokens 2.x
Fetches replacements for the provided tokens.
Parameters
array $tokens: The tokens.
Return value
array The replacements.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
TokenReplacer.php, line 209
Class
- TokenReplacer
- Class TokenReplacer.
Namespace
Drupal\aetCode
public function getReplacements(array $tokens) {
$replacements = [];
// Checks all entities to see if they exist in the list of tokens.
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type_info) {
$token_type = $entity_type_info
->get('additional')['token_type'] ?: $entity_type_id;
$tokens_for_type = $this->tokenService
->findWithPrefix($tokens, $token_type);
$replacements += $this
->getReplacementsForTokenType($token_type, $tokens_for_type);
}
// Clears unreplaced tokens if the option is flagged.
return $this
->getReplacementsWithUnreplacedTokensClearedIfSet($tokens, $replacements);
}