Skip to content

Commit

Permalink
TASK: integrate setting for removed node redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoldbeck committed May 4, 2018
1 parent 34b7685 commit bf3717d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Classes/Service/NodeRedirectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class NodeRedirectService implements NodeRedirectServiceInterface
*/
protected $defaultStatusCode;

/**
* @Flow\InjectConfiguration(path="enableRemovedNodeRedirect", package="Neos.RedirectHandler.NeosAdapter")
* @var array
*/
protected $enableRemovedNodeRedirect;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 7 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bf3717d

Please sign in to comment.