Skip to content

Commit

Permalink
Merge pull request #20 from mindscreen/feature/removed-nodes-redirect…
Browse files Browse the repository at this point in the history
…-handling

Configurable node isRemoved handling
  • Loading branch information
mgoldbeck authored May 30, 2018
2 parents 34b7685 + bf3717d commit b7d74d2
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 b7d74d2

Please sign in to comment.