mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Fixes relating to Controller cleanup
This commit is contained in:
parent
933a294478
commit
e04e992c73
@ -131,7 +131,7 @@ class ContentController extends Controller {
|
|||||||
* @return SS_HTTPResponse
|
* @return SS_HTTPResponse
|
||||||
* @throws SS_HTTPResponse_Exception
|
* @throws SS_HTTPResponse_Exception
|
||||||
*/
|
*/
|
||||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||||
$child = null;
|
$child = null;
|
||||||
$action = $request->param('Action');
|
$action = $request->param('Action');
|
||||||
$this->setDataModel($model);
|
$this->setDataModel($model);
|
||||||
|
@ -40,6 +40,20 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
parent::init();
|
parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function beforeHandleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||||
|
parent::beforeHandleRequest($request, $model);
|
||||||
|
// If the database has not yet been created, redirect to the build page.
|
||||||
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
|
$this->getResponse()->redirect(Controller::join_links(
|
||||||
|
Director::absoluteBaseURL(),
|
||||||
|
'dev/build',
|
||||||
|
'?' . array(
|
||||||
|
'returnURL' => isset($_GET['url']) ? $_GET['url'] : null,
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses ModelAsController::getNestedController()
|
* @uses ModelAsController::getNestedController()
|
||||||
* @param SS_HTTPRequest $request
|
* @param SS_HTTPRequest $request
|
||||||
@ -47,12 +61,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
* @return SS_HTTPResponse
|
* @return SS_HTTPResponse
|
||||||
*/
|
*/
|
||||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||||
$this->setRequest($request);
|
$this->beforeHandleRequest($request, $model);
|
||||||
$this->setDataModel($model);
|
|
||||||
|
|
||||||
$this->pushCurrent();
|
|
||||||
$this->getResponse();
|
|
||||||
$this->init();
|
|
||||||
|
|
||||||
// If we had a redirection or something, halt processing.
|
// If we had a redirection or something, halt processing.
|
||||||
if($this->getResponse()->isFinished()) {
|
if($this->getResponse()->isFinished()) {
|
||||||
|
@ -106,6 +106,22 @@ class RootURLController extends Controller {
|
|||||||
self::$cached_homepage_link = null;
|
self::$cached_homepage_link = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function beforeHandleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||||
|
parent::beforeHandleRequest($request, $model);
|
||||||
|
|
||||||
|
self::$is_at_root = true;
|
||||||
|
|
||||||
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
|
$this->getResponse()->redirect(Controller::join_links(
|
||||||
|
Director::absoluteBaseURL(),
|
||||||
|
'dev/build',
|
||||||
|
'?' . array(
|
||||||
|
'returnURL' => isset($_GET['url']) ? $_GET['url'] : null,
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SS_HTTPRequest $request
|
* @param SS_HTTPRequest $request
|
||||||
* @param DataModel|null $model
|
* @param DataModel|null $model
|
||||||
@ -113,12 +129,10 @@ class RootURLController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
||||||
self::$is_at_root = true;
|
self::$is_at_root = true;
|
||||||
$this->setDataModel($model);
|
$this->beforeHandleRequest($request, $model);
|
||||||
|
|
||||||
$this->pushCurrent();
|
if (!$this->getResponse()->isFinished()) {
|
||||||
$this->init();
|
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
|
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
|
||||||
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
return $this->getResponse();
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
@ -127,10 +141,14 @@ class RootURLController extends Controller {
|
|||||||
$request->match('$URLSegment//$Action', true);
|
$request->match('$URLSegment//$Action', true);
|
||||||
$controller = new ModelAsController();
|
$controller = new ModelAsController();
|
||||||
|
|
||||||
$result = $controller->handleRequest($request, $model);
|
$response = $controller->handleRequest($request, $model);
|
||||||
|
|
||||||
$this->popCurrent();
|
$this->prepareResponse($response);
|
||||||
return $result;
|
}
|
||||||
|
|
||||||
|
$this->afterHandleRequest();
|
||||||
|
|
||||||
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user