From c4fa79519d1a8fae61de7cb810d0ffb6fddd27f8 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Wed, 24 May 2023 17:58:27 +0200 Subject: [PATCH] TASK: Make linter happy --- .../Domain/Repository/EditPreviewModeRepository.php | 2 +- .../Classes/FrontendRouting/NodeUriBuilder.php | 9 ++++++--- Neos.Neos/Classes/Fusion/Helper/BackendHelper.php | 13 +++++++++---- Neos.Neos/Classes/Service/LinkingService.php | 5 +++-- .../Fusion/Override/GlobalCacheIdentifiers.fusion | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Neos.Neos/Classes/Domain/Repository/EditPreviewModeRepository.php b/Neos.Neos/Classes/Domain/Repository/EditPreviewModeRepository.php index bc392d0c873..d93a391c0b1 100644 --- a/Neos.Neos/Classes/Domain/Repository/EditPreviewModeRepository.php +++ b/Neos.Neos/Classes/Domain/Repository/EditPreviewModeRepository.php @@ -36,7 +36,7 @@ public function findDefault(): EditPreviewMode public function findByName(string $name): EditPreviewMode { - if (array_key_exists($name,$this->editPreviewModeConfigurations)) { + if (array_key_exists($name, $this->editPreviewModeConfigurations)) { return EditPreviewMode::fromNameAndConfiguration($name, $this->editPreviewModeConfigurations[$name]); } throw new InvalidEditPreviewModeException(sprintf('"%s" is not a valid editPreviewMode', $name), 1683790077); diff --git a/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php b/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php index e042b2b954a..571652c8893 100644 --- a/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php +++ b/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php @@ -66,13 +66,16 @@ public function uriFor(NodeAddress $nodeAddress): UriInterface { if (!$nodeAddress->isInLiveWorkspace()) { $request = $this->uriBuilder->getRequest(); - if ($request->getControllerPackageKey() === 'Neos.Neos' + if ( + $request->getControllerPackageKey() === 'Neos.Neos' && $request->getControllerName() === "Frontend\Node" ) { if ($request->getControllerActionName() == 'edit') { - return $this->editUriFor($nodeAddress, $request->hasArgument('editPreviewMode') ? $request->getArgument('editPreviewMode') : null); + $editPreviewModeArgument = $request->hasArgument('editPreviewMode') ? $request->getArgument('editPreviewMode') : null; + return $this->editUriFor($nodeAddress, is_string($editPreviewModeArgument) ? $editPreviewModeArgument : null); } elseif ($request->getControllerActionName() == 'preview') { - return $this->previewUriFor($nodeAddress, $request->hasArgument('editPreviewMode') ? $request->getArgument('editPreviewMode') : null); + $editPreviewModeArgument = $request->hasArgument('editPreviewMode') ? $request->getArgument('editPreviewMode') : null; + return $this->previewUriFor($nodeAddress, is_string($editPreviewModeArgument) ? $editPreviewModeArgument : null); } } diff --git a/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php b/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php index dfebb300a32..990d100deed 100644 --- a/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php @@ -57,15 +57,20 @@ public function isPreviewMode(ActionRequest $request): bool ); } - public function editPreviewModeCacheIdentifier(ActionRequest $request): string + public function renderingModeCacheIdentifier(ActionRequest $request): string { - if ($request->getControllerPackageKey() === 'Neos.Neos' + if ( + $request->getControllerPackageKey() === 'Neos.Neos' && $request->getControllerName() === "Frontend\Node" && ($request->getControllerActionName() === 'edit' || $request->getControllerActionName() === 'preview') ) { - return $request->getControllerActionName() . ($request->hasArgument('editPreviewMode') ? ':' . $request->getArgument('editPreviewMode') : ''); + $editPreviewModeArgument = $request->hasArgument('editPreviewMode') ? $request->getArgument('editPreviewMode') : null; + if (is_string($editPreviewModeArgument)) { + return $request->getControllerActionName() . ':' . $editPreviewModeArgument; + } + return $request->getControllerActionName(); } else { - return ""; + return "show"; } } diff --git a/Neos.Neos/Classes/Service/LinkingService.php b/Neos.Neos/Classes/Service/LinkingService.php index a1eb2b7235f..19b70bb4b4b 100644 --- a/Neos.Neos/Classes/Service/LinkingService.php +++ b/Neos.Neos/Classes/Service/LinkingService.php @@ -370,12 +370,13 @@ public function createNodeUri( $uriBuilder = clone $controllerContext->getUriBuilder(); $uriBuilder->setRequest($request); - if ($request->getControllerPackageKey() === 'Neos.Neos' + if ( + $request->getControllerPackageKey() === 'Neos.Neos' && $request->getControllerName() === "Frontend\Node" && in_array($request->getControllerActionName(), ['edit', 'preview']) ) { $action = $request->getControllerActionName(); - if ( $request->hasArgument('editPreviewMode')) { + if ($request->hasArgument('editPreviewMode')) { $arguments['editPreviewMode'] = $request->getArgument('editPreviewMode'); } } else { diff --git a/Neos.Neos/Resources/Private/Fusion/Override/GlobalCacheIdentifiers.fusion b/Neos.Neos/Resources/Private/Fusion/Override/GlobalCacheIdentifiers.fusion index e28d9f67e91..f4980c77ddb 100644 --- a/Neos.Neos/Resources/Private/Fusion/Override/GlobalCacheIdentifiers.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Override/GlobalCacheIdentifiers.fusion @@ -6,5 +6,5 @@ prototype(Neos.Fusion:GlobalCacheIdentifiers) { workspaceChain = ${Array.join(Array.keys(Neos.Caching.getWorkspaceChain(documentNode)), ',')} workspaceChain.@if.has = ${!!documentNode} - editPreviewMode = ${Neos.Backend.editPreviewModeCacheIdentifier(request)} + renderingMode = ${Neos.Backend.renderingModeCacheIdentifier(request)} }