mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
MINOR Use instance methods on current Controller instance for redirect()
instead of static Director functions
This commit is contained in:
parent
9598080368
commit
ec3ebc91d8
@ -90,19 +90,19 @@ class ContentController extends Controller {
|
||||
// If we've accessed the homepage as /home/, then we should redirect to /.
|
||||
if($this->dataRecord && $this->dataRecord instanceof SiteTree
|
||||
&& RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action'] )
|
||||
&& !$_POST && !$_FILES && !Director::redirected_to() ) {
|
||||
&& !$_POST && !$_FILES && !$this->redirectedTo() ) {
|
||||
$getVars = $_GET;
|
||||
unset($getVars['url']);
|
||||
if($getVars) $url = "?" . http_build_query($getVars);
|
||||
else $url = "";
|
||||
Director::redirect($url, 301);
|
||||
$this->redirect($url, 301);
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->dataRecord) $this->dataRecord->extend('contentcontrollerInit', $this);
|
||||
else singleton('SiteTree')->extend('contentcontrollerInit', $this);
|
||||
|
||||
if(Director::redirected_to()) return;
|
||||
if($this->redirectedTo()) return;
|
||||
|
||||
// Check page permissions
|
||||
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
||||
|
@ -273,7 +273,7 @@ class ErrorPage_Controller extends Page_Controller {
|
||||
|
||||
$action = $this->request->param('Action');
|
||||
if(!$action || $action == 'index') {
|
||||
Director::set_status_code($this->failover->ErrorCode ? $this->failover->ErrorCode : 404);
|
||||
$this->getResponse()->setStatusCode($this->failover->ErrorCode ? $this->failover->ErrorCode : 404);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -166,12 +166,14 @@ class RedirectorPage extends Page {
|
||||
* @subpackage content
|
||||
*/
|
||||
class RedirectorPage_Controller extends Page_Controller {
|
||||
function init() {
|
||||
if($link = $this->redirectionLink()) {
|
||||
Director::redirect($link, 301);
|
||||
}
|
||||
|
||||
function init() {
|
||||
parent::init();
|
||||
|
||||
if($link = $this->redirectionLink()) {
|
||||
$this->redirect($link, 301);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user