add __invoke() method

This commit is contained in:
Uwe Steinmann 2017-05-12 08:15:26 +02:00
parent 3de40aa6b1
commit 19aa2b5e45

View File

@ -41,6 +41,24 @@ class SeedDMS_Controller_Common {
$this->errormsg = '';
}
/**
* Call methods with name in $get['action']
*
* @params array $get $_GET or $_POST variables
* @return mixed return value of called method
*/
function __invoke($get=array()) {
if(isset($get['action']) && $get['action']) {
if(method_exists($this, $get['action'])) {
return $this->{$get['action']}();
} else {
echo "Missing action '".$get['action']."'";
return false;
}
} else
return $this->run();
}
function setParams($params) {
$this->params = $params;
}