Merge pull request #295 from shanelja/master

Attempting to execute unmapped methods now triggers Exceptions
pull/301/head
Mike Cao 8 years ago committed by GitHub
commit b4b43460eb

@ -272,6 +272,16 @@ class Engine {
$this->loader->addDirectory($dir);
}
/**
* Checks for mapped event within the engine dispatcher.
*
* @param $name
* @return bool
*/
public function isEvent($name) {
return !is_null($this->dispatcher->get($name));
}
/*** Extensible Methods ***/
/**

@ -69,15 +69,20 @@ class Flight {
* @param string $name Method name
* @param array $params Method parameters
* @return mixed Callback results
* @throws \Exception
*/
public static function __callStatic($name, $params) {
$app = Flight::app();
if (!method_exists($app, $name) && !$app->isEvent($name)) {
throw new \Exception("{$name} must be a mapped method");
}
return \flight\core\Dispatcher::invokeMethod(array($app, $name), $params);
}
/**
* @return object Application instance
* @return \flight\Engine Application instance
*/
public static function app() {
static $initialized = false;

Loading…
Cancel
Save