From c7b22eca375a1050b4a4b6ec5d8898386d68eb2d Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Mon, 19 Jun 2023 14:29:09 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Bastian Waidelich Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com> --- .../Classes/Fusion/Helper/BackendHelper.php | 16 ++++++---------- Neos.Neos/Classes/Service/LinkingService.php | 6 +----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php b/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php index 990d100deed..a72199ebddb 100644 --- a/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/BackendHelper.php @@ -41,29 +41,25 @@ public function interfaceLanguage(): string return $this->userService->getInterfaceLanguage(); } - public function isEditMode(ActionRequest $request): bool + public static function isEditMode(ActionRequest $request): bool { return ($request->getControllerPackageKey() === 'Neos.Neos' - && $request->getControllerName() === "Frontend\Node" + && $request->getControllerName() === 'Frontend\\Node' && $request->getControllerActionName() === 'edit' ); } - public function isPreviewMode(ActionRequest $request): bool + public static function isPreviewMode(ActionRequest $request): bool { return ($request->getControllerPackageKey() === 'Neos.Neos' - && $request->getControllerName() === "Frontend\Node" + && $request->getControllerName() === 'Frontend\\Node' && $request->getControllerActionName() === 'preview' ); } - public function renderingModeCacheIdentifier(ActionRequest $request): string + public static function renderingModeCacheIdentifier(ActionRequest $request): string { - if ( - $request->getControllerPackageKey() === 'Neos.Neos' - && $request->getControllerName() === "Frontend\Node" - && ($request->getControllerActionName() === 'edit' || $request->getControllerActionName() === 'preview') - ) { + if ($this->isEditMode($request) || $this->isPreviewMode($request)) { $editPreviewModeArgument = $request->hasArgument('editPreviewMode') ? $request->getArgument('editPreviewMode') : null; if (is_string($editPreviewModeArgument)) { return $request->getControllerActionName() . ':' . $editPreviewModeArgument; diff --git a/Neos.Neos/Classes/Service/LinkingService.php b/Neos.Neos/Classes/Service/LinkingService.php index d75d9dd152d..4168879b9d5 100644 --- a/Neos.Neos/Classes/Service/LinkingService.php +++ b/Neos.Neos/Classes/Service/LinkingService.php @@ -370,11 +370,7 @@ public function createNodeUri( $uriBuilder = clone $controllerContext->getUriBuilder(); $uriBuilder->setRequest($request); - if ( - $request->getControllerPackageKey() === 'Neos.Neos' - && $request->getControllerName() === "Frontend\Node" - && in_array($request->getControllerActionName(), ['edit', 'preview']) - ) { + if (BackendHelper::isEditMode($request) || BackendHelper::isPreviewMode($request)) { $action = $request->getControllerActionName(); if ($request->hasArgument('editPreviewMode')) { $arguments['editPreviewMode'] = $request->getArgument('editPreviewMode');