mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-01 07:17:48 +02:00
BUGFIX: Let ModelAsController::init() extensions trigger redirections. (from r97767)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98221 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ba02e1dc9f
commit
5efb72ce26
@ -19,7 +19,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
public static function controller_for(SiteTree $sitetree, $action = null) {
|
public static function controller_for(SiteTree $sitetree, $action = null) {
|
||||||
if($sitetree->class == 'SiteTree') $controller = "ContentController";
|
if($sitetree->class == 'SiteTree') $controller = "ContentController";
|
||||||
else $controller = "{$sitetree->class}_Controller";
|
else $controller = "{$sitetree->class}_Controller";
|
||||||
|
|
||||||
if($action && class_exists($controller . '_' . ucfirst($action))) {
|
if($action && class_exists($controller . '_' . ucfirst($action))) {
|
||||||
$controller = $controller . '_' . ucfirst($action);
|
$controller = $controller . '_' . ucfirst($action);
|
||||||
}
|
}
|
||||||
@ -29,6 +29,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
singleton('SiteTree')->extend('modelascontrollerInit', $this);
|
singleton('SiteTree')->extend('modelascontrollerInit', $this);
|
||||||
|
parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,11 +40,14 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
||||||
$this->pushCurrent();
|
$this->pushCurrent();
|
||||||
|
|
||||||
|
// Create a response just in case init() decides to redirect
|
||||||
|
$this->response = new SS_HTTPResponse();
|
||||||
|
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
// If the database has not yet been created, redirect to the build page.
|
// If the database has not yet been created, redirect to the build page.
|
||||||
if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) {
|
if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->response = new SS_HTTPResponse();
|
|
||||||
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
$this->popCurrent();
|
$this->popCurrent();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user