From bf3717d61d0a62c0074892570a673207e0beba04 Mon Sep 17 00:00:00 2001 From: Markus Goldbeck Date: Fri, 4 May 2018 14:57:47 +0200 Subject: [PATCH] TASK: integrate setting for removed node redirect --- Classes/Service/NodeRedirectService.php | 18 +++++++++++++++--- Configuration/Settings.yaml | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100755 Configuration/Settings.yaml diff --git a/Classes/Service/NodeRedirectService.php b/Classes/Service/NodeRedirectService.php index 3ba223c..6fb16e6 100644 --- a/Classes/Service/NodeRedirectService.php +++ b/Classes/Service/NodeRedirectService.php @@ -85,6 +85,12 @@ class NodeRedirectService implements NodeRedirectServiceInterface */ protected $defaultStatusCode; + /** + * @Flow\InjectConfiguration(path="enableRemovedNodeRedirect", package="Neos.RedirectHandler.NeosAdapter") + * @var array + */ + protected $enableRemovedNodeRedirect; + /** * {@inheritdoc} */ @@ -133,9 +139,15 @@ protected function executeRedirectsForPublishedNode(NodeInterface $node, Workspa // The page has been removed if ($node->isRemoved()) { - $this->flushRoutingCacheForNode($targetNode); - $statusCode = (integer)$this->defaultStatusCode['gone']; - $this->redirectStorage->addRedirect($targetNodeUriPath, '', $statusCode, $hosts); + // By default the redirect handling for removed nodes is activated. + // If it is deactivated in your settings you will be able to handle the redirects on your own. + // For example redirect to dedicated landing pages for deleted campaign NodeTypes + if ($this->enableRemovedNodeRedirect) { + $this->flushRoutingCacheForNode($targetNode); + $statusCode = (integer)$this->defaultStatusCode['gone']; + $this->redirectStorage->addRedirect($targetNodeUriPath, '', $statusCode, $hosts); + } + return; } diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml new file mode 100755 index 0000000..caed407 --- /dev/null +++ b/Configuration/Settings.yaml @@ -0,0 +1,7 @@ +Neos: + RedirectHandler: + NeosAdapter: + # By default the redirect handling for removed nodes is activated. + # If it is deactivated in your settings you will be able to handle the redirects on your own. + # For example redirect to dedicated landing pages for deleted campaign NodeTypes + enableRemovedNodeRedirect: true