mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX Allow RedirectorPage to have non-redirected actions, move redirection to index
This commit is contained in:
parent
ecbd778547
commit
c2ad41ef1b
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace SilverStripe\CMS\Model;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Control\HTTPRequest;
|
||||||
use PageController;
|
use PageController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,26 +9,31 @@ use PageController;
|
|||||||
*/
|
*/
|
||||||
class RedirectorPageController extends PageController
|
class RedirectorPageController extends PageController
|
||||||
{
|
{
|
||||||
|
private static $allowed_actions = ['index'];
|
||||||
|
|
||||||
protected function init()
|
/**
|
||||||
|
* Check we don't already have a redirect code set
|
||||||
|
*
|
||||||
|
* @param HTTPRequest $request
|
||||||
|
* @return \SilverStripe\Control\HTTPResponse
|
||||||
|
*/
|
||||||
|
public function index(HTTPRequest $request)
|
||||||
{
|
{
|
||||||
parent::init();
|
|
||||||
|
|
||||||
// Check we don't already have a redirect code set
|
|
||||||
/** @var RedirectorPage $page */
|
/** @var RedirectorPage $page */
|
||||||
$page = $this->data();
|
$page = $this->data();
|
||||||
if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
|
if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
|
||||||
$this->redirect($link, 301);
|
$this->redirect($link, 301);
|
||||||
}
|
}
|
||||||
|
return parent::handleAction($request, 'handleIndex');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we ever get this far, it means that the redirection failed.
|
* If we ever get this far, it means that the redirection failed.
|
||||||
*/
|
*/
|
||||||
public function Content()
|
public function getContent()
|
||||||
{
|
{
|
||||||
return "<p class=\"message-setupWithoutRedirect\">" .
|
return "<p class=\"message-setupWithoutRedirect\">" .
|
||||||
_t('SilverStripe\\CMS\\Model\\RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
|
_t(__CLASS__ . '.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
|
||||||
"</p>";
|
"</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,4 +204,3 @@ class ContentControllerTest extends FunctionalTest
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user