From 056abb8dcd6482adcf4dfc0538492c045542fa8c Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Wed, 25 Jun 2025 16:49:56 +0200 Subject: [PATCH] fix: preview mode by using the node canonical routes --- modules/next/src/NextEntityTypeManager.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/next/src/NextEntityTypeManager.php b/modules/next/src/NextEntityTypeManager.php index b0950503f..f11bb9d7b 100644 --- a/modules/next/src/NextEntityTypeManager.php +++ b/modules/next/src/NextEntityTypeManager.php @@ -66,14 +66,22 @@ public function getEntityFromRouteMatch(RouteMatchInterface $route_match): ?Enti $entity_types_ids = $this->getConfigEntityTypeIds(); // @todo Handle all revisionable entity types. - $revision_routes = ['entity.node.revision', 'entity.node.latest_version']; + $revision_routes = [ + 'entity.node.canonical', + 'entity.node.revision', + 'entity.node.latest_version', + ]; + if (in_array($route_match->getRouteName(), $revision_routes) && in_array('node', $entity_types_ids)) { $node_revision = $route_match->getParameter('node_revision'); if ($node_revision instanceof NodeInterface) { return $node_revision; } - if ($route_match->getRouteName() === 'entity.node.latest_version') { + if ( + $route_match->getRouteName() === 'entity.node.latest_version' || + $route_match->getRouteName() === 'entity.node.canonical' + ) { $node_revision = $route_match->getParameter('node')->getRevisionId(); }