Skip to content
Snippets Groups Projects

Issue #3308559 - Provides replacement for <id> and <uuid> if both present

Merged Andor requested to merge issue/aet-3308559:3308559-id-overrules-uuid into 2.x
1 file
+ 21
4
Compare changes
  • Side-by-side
  • Inline
+ 21
4
@@ -452,11 +452,28 @@ class TokenReplacer {
@@ -452,11 +452,28 @@ class TokenReplacer {
*/
*/
protected function getWholeEntityReplacements(string $entity_type_id, EntityInterface $entity, array $tokens) {
protected function getWholeEntityReplacements(string $entity_type_id, EntityInterface $entity, array $tokens) {
$replacements = [];
$replacements = [];
if (isset($tokens[$entity->id()]) || isset($tokens[$entity->uuid()])) {
$view_mode = isset($this->entityDisplayRepository->getViewModes($entity_type_id)['token']) ? 'token' : 'full';
$has_id = isset($tokens[$entity->id()]);
$id = isset($tokens[$entity->id()]) ? $entity->id() : $entity->uuid();
$has_uuid = isset($tokens[$entity->uuid()]);
$replacements[$tokens[$id]] = $this->getRenderedEntity($entity_type_id, $entity, $view_mode);
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;
return $replacements;
}
}
Loading