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

instead of static Director functions
This commit is contained in:
Sean Harvey 2012-05-23 21:45:16 +12:00
parent 9598080368
commit ec3ebc91d8
3 changed files with 10 additions and 8 deletions

View File

@ -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()) {

View File

@ -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);
}
}

View File

@ -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;
}
}
/**