mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 09:35:00 +00:00
call hook preRun and check result
This commit is contained in:
parent
718d922950
commit
8b75ffaea1
|
@ -45,17 +45,38 @@ class SeedDMS_View_Common {
|
|||
$this->imgpath = '../views/'.$theme.'/images/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Call method with name in $get['action']
|
||||
*
|
||||
* Until 5.1.26 (6.0.19) this method took the name of the
|
||||
* controller method to run from the element 'action' passed
|
||||
* in the array $get. Since 5.1.27 (6.0.20) a PSR7 Request
|
||||
* object is available in the controller and used to get the
|
||||
* action.
|
||||
*
|
||||
* @params array $get $_GET or $_POST variables (since 5.1.27 this is no longer used)
|
||||
* @return mixed return value of called method
|
||||
*/
|
||||
public function __invoke($get=array()) {
|
||||
$this->callHook('preRun', isset($get['action']) ? $get['action'] : 'show');
|
||||
if(isset($get['action']) && $get['action']) {
|
||||
if(method_exists($this, $get['action'])) {
|
||||
$this->{$get['action']}();
|
||||
} else {
|
||||
echo "Missing action '".htmlspecialchars($get['action'])."'";
|
||||
}
|
||||
} else
|
||||
$this->show();
|
||||
$this->callHook('postRun', isset($get['action']) ? $get['action'] : 'show');
|
||||
$action = null;
|
||||
$request = $this->getParam('request');
|
||||
if($request) {
|
||||
if($request->isMethod('get'))
|
||||
$action = $request->query->get('action');
|
||||
elseif($request->isMethod('post'))
|
||||
$action = $request->request->get('action');
|
||||
}
|
||||
if(!$this->callHook('preRun', $action ? $action : 'show')) {
|
||||
if($action) {
|
||||
if(method_exists($this, $action)) {
|
||||
$this->{$action}();
|
||||
} else {
|
||||
echo "Missing action '".htmlspecialchars($action)."'";
|
||||
}
|
||||
} else
|
||||
$this->show();
|
||||
}
|
||||
$this->callHook('postRun', $action ? $action : 'show');
|
||||
}
|
||||
|
||||
public function setParams($params) {
|
||||
|
@ -78,7 +99,7 @@ class SeedDMS_View_Common {
|
|||
* @param string $name name of parameter
|
||||
* @return boolean true if parameter exists otherwise false
|
||||
*/
|
||||
function hasParam($name) {
|
||||
public function hasParam($name) {
|
||||
return isset($this->params[$name]) ? true : false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user