mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
More precise controller callbacks execution, new callback shutdown()
This commit is contained in:
@@ -137,7 +137,7 @@ class eFront
|
|||||||
// dispatched status true on first loop
|
// dispatched status true on first loop
|
||||||
$router->checkLegacy($request);
|
$router->checkLegacy($request);
|
||||||
|
|
||||||
// dispatched by default - don't allow legacy to alter dsiaptch status
|
// dispatched by default - don't allow legacy to alter dispatch status
|
||||||
$request->setDispatched(true);
|
$request->setDispatched(true);
|
||||||
|
|
||||||
// legacy mod - return control to the bootstrap
|
// legacy mod - return control to the bootstrap
|
||||||
@@ -2634,9 +2634,24 @@ class eController
|
|||||||
->init();
|
->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom init, always called in the constructor, no matter what is the request dispatch status
|
||||||
|
*/
|
||||||
public function init() {}
|
public function init() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom shutdown, always called after the controller dispatch, no matter what is the request dispatch status
|
||||||
|
*/
|
||||||
|
public function shutdown() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre-action callback, fired only if dispatch status is still true and action method is found
|
||||||
|
*/
|
||||||
public function preAction() {}
|
public function preAction() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post-action callback, fired only if dispatch status is still true and action method is found
|
||||||
|
*/
|
||||||
public function postAction() {}
|
public function postAction() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2703,18 +2718,26 @@ class eController
|
|||||||
|
|
||||||
public function dispatch($actionMethodName)
|
public function dispatch($actionMethodName)
|
||||||
{
|
{
|
||||||
$this->preAction();
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
// init() could modify the dispatch status
|
||||||
if($request->isDispatched())
|
if($request->isDispatched())
|
||||||
{
|
{
|
||||||
if(method_exists($this, $actionMethodName))
|
if(method_exists($this, $actionMethodName))
|
||||||
{
|
{
|
||||||
|
$this->preAction();
|
||||||
// TODO request userParams() to store private data - check for noPopulate param here
|
// TODO request userParams() to store private data - check for noPopulate param here
|
||||||
|
if($request->isDispatched())
|
||||||
|
{
|
||||||
$request->populateRequestParams();
|
$request->populateRequestParams();
|
||||||
$this->$actionMethodName();
|
$this->$actionMethodName();
|
||||||
|
|
||||||
|
if($request->isDispatched())
|
||||||
|
{
|
||||||
$this->postAction();
|
$this->postAction();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO not found method by controller or default one
|
//TODO not found method by controller or default one
|
||||||
@@ -2722,6 +2745,7 @@ class eController
|
|||||||
throw new eException('Action "'.$action.'" does not exist');
|
throw new eException('Action "'.$action.'" does not exist');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(eRequest $request = null, eResponse $response = null)
|
public function run(eRequest $request = null, eResponse $response = null)
|
||||||
|
Reference in New Issue
Block a user