Skip to content
Snippets Groups Projects
Commit a5ad7c70 authored by Andor's avatar Andor Committed by Eyal Shalev
Browse files

Issue #3308559 by Sweetchuck: ID overrules the UUID

parent 56ac132c
No related branches found
No related tags found
1 merge request!1Issue #3308559 - Provides replacement for <id> and <uuid> if both present
......@@ -452,11 +452,28 @@ class TokenReplacer {
*/
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);
$has_id = isset($tokens[$entity->id()]);
$has_uuid = isset($tokens[$entity->uuid()]);
if (!$has_id && !$has_uuid) {
return $replacements;
}
$available_view_modes = $this->entityDisplayRepository->getViewModes($entity_type_id);
$rendered_entity = $this->getRenderedEntity(
$entity_type_id,
$entity,
isset($available_view_modes['token']) ? 'token' : 'full'
);
if ($has_id) {
$replacements[$tokens[$entity->id()]] = $rendered_entity;
}
if ($has_uuid) {
$replacements[$tokens[$entity->uuid()]] = $rendered_entity;
}
return $replacements;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment