diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index 756a1dd642c..f5ae466fd07 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -47,9 +47,6 @@ use Neos\Neos\Utility\NodeTypeWithFallbackProvider; use Neos\Neos\View\FusionView; -/** - * Event Sourced Node Controller; as Replacement of NodeController - */ class NodeController extends ActionController { use NodeTypeWithFallbackProvider; @@ -110,7 +107,7 @@ class NodeController extends ActionController protected int $shortcutRedirectHttpStatusCode; /** - * @param string $node Legacy name for backwards compatibility of route components + * @param string $node * @throws NodeNotFoundException * @throws \Neos\Flow\Mvc\Exception\StopActionException * @throws \Neos\Flow\Mvc\Routing\Exception\MissingActionNameException @@ -157,7 +154,11 @@ public function previewAction(string $node): void ); } - if ($this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT) && $nodeAddress->isInLiveWorkspace()) { + if ( + $this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT) + && !$renderingMode->isEdit + && $nodeAddress->workspaceName->isLive() // shortcuts are only resolvable for the live workspace + ) { $this->handleShortcutNode($nodeAddress, $contentRepository); } @@ -168,7 +169,7 @@ public function previewAction(string $node): void 'site' => $site, ]); - if (!$nodeAddress->isInLiveWorkspace()) { + if ($renderingMode->isEdit) { $this->overrideViewVariablesFromInternalArguments(); $this->response->setHttpHeader('Cache-Control', 'no-cache'); if (!$this->view->canRenderWithNodeAndPath()) { @@ -266,7 +267,7 @@ protected function overrideViewVariablesFromInternalArguments() } /** - * Handles redirects to shortcut targets in live rendering. + * Handles redirects to shortcut targets of nodes in the live workspace. * * @param NodeAddress $nodeAddress * @throws NodeNotFoundException diff --git a/Neos.Neos/Classes/Domain/Model/RenderingMode.php b/Neos.Neos/Classes/Domain/Model/RenderingMode.php index 389f23c1f2f..347ea1e062a 100644 --- a/Neos.Neos/Classes/Domain/Model/RenderingMode.php +++ b/Neos.Neos/Classes/Domain/Model/RenderingMode.php @@ -20,14 +20,14 @@ * Describes the mode in which the Neos interface is rendering currently, * mainly distinguishing between edit and preview modes currently. */ -class RenderingMode +final class RenderingMode { public const FRONTEND = 'frontend'; /** * @param array $options */ - public function __construct( + private function __construct( public readonly string $name, public readonly bool $isEdit, public readonly bool $isPreview, @@ -52,7 +52,7 @@ public static function createFromConfiguration(string $modeName, array $configur 1694802951840 ); } - $mode = new RenderingMode( + return new self( $modeName, $configuration['isEditingMode'] ?? false, $configuration['isPreviewMode'] ?? false, @@ -60,7 +60,6 @@ public static function createFromConfiguration(string $modeName, array $configur $configuration['fusionRenderingPath'] ?? '', $configuration['options'] ?? [], ); - return $mode; } /** @@ -68,7 +67,7 @@ public static function createFromConfiguration(string $modeName, array $configur */ public static function createFrontend(): RenderingMode { - return new RenderingMode( + return new self( RenderingMode::FRONTEND, false, false, diff --git a/Neos.Neos/Classes/FrontendRouting/NodeShortcutResolver.php b/Neos.Neos/Classes/FrontendRouting/NodeShortcutResolver.php index d1d6ad5b679..a63351f3569 100644 --- a/Neos.Neos/Classes/FrontendRouting/NodeShortcutResolver.php +++ b/Neos.Neos/Classes/FrontendRouting/NodeShortcutResolver.php @@ -64,6 +64,9 @@ public function __construct( */ public function resolveShortcutTarget(NodeAddress $nodeAddress, ContentRepository $contentRepository) { + if (!$nodeAddress->workspaceName->isLive()) { + throw new \RuntimeException(sprintf('Cannot resolve shortcut target for node-address %s in workspace %s because the DocumentUriPathProjection only handles the live workspace.', $nodeAddress->nodeAggregateId->value, $nodeAddress->workspaceName->value), 1707208650); + } $documentUriPathFinder = $contentRepository->projectionState(DocumentUriPathFinder::class); $documentNodeInfo = $documentUriPathFinder->getByIdAndDimensionSpacePointHash( $nodeAddress->nodeAggregateId,