Skip to content
Browse files

MINOR Use instance methods on current Controller instance for redirect()

instead of static Director functions
  • Loading branch information...
1 parent 9598080 commit ec3ebc91d84fa343c1ef8d093d0e80b2af664ddf @halkyon halkyon committed May 23, 2012
Showing with 9 additions and 7 deletions.
  1. +3 −3 code/controllers/ContentController.php
  2. +1 −1 code/model/ErrorPage.php
  3. +5 −3 code/model/RedirectorPage.php
View
6 code/controllers/ContentController.php
@@ -90,19 +90,19 @@ public function init() {
// 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()) {
View
2 code/model/ErrorPage.php
@@ -273,7 +273,7 @@ function init() {
$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);
}
}
View
8 code/model/RedirectorPage.php
@@ -166,12 +166,14 @@ function subPagesToCache() {
* @subpackage content
*/
class RedirectorPage_Controller extends Page_Controller {
+
function init() {
+ parent::init();
+
if($link = $this->redirectionLink()) {
- Director::redirect($link, 301);
+ $this->redirect($link, 301);
+ return;
}
-
- parent::init();
}
/**

0 comments on commit ec3ebc9

Please sign in to comment.
Something went wrong with that request. Please try again.