From ec3ebc91d84fa343c1ef8d093d0e80b2af664ddf Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 23 May 2012 21:45:16 +1200 Subject: [PATCH] MINOR Use instance methods on current Controller instance for redirect() instead of static Director functions --- code/controllers/ContentController.php | 6 +++--- code/model/ErrorPage.php | 2 +- code/model/RedirectorPage.php | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index 0aa02009..8440bef8 100644 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -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()) { diff --git a/code/model/ErrorPage.php b/code/model/ErrorPage.php index ae7c627e..67548e82 100644 --- a/code/model/ErrorPage.php +++ b/code/model/ErrorPage.php @@ -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); } } diff --git a/code/model/RedirectorPage.php b/code/model/RedirectorPage.php index 8cfcdd61..102ba68f 100644 --- a/code/model/RedirectorPage.php +++ b/code/model/RedirectorPage.php @@ -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; + } } /**