/** * __construct() * check if init() method is declared and runs * @see \NG\Route * @see \NG\View * @access public * @return void */ public function __construct() { $className = \NG\Route::getController(); $method = \NG\Route::getAction(); $this->view = new \NG\View($className, $method); if (method_exists($this, 'init')) { $this->init(); } }
/** * _loadController() * Loads application controller * @see \NG\Route * @throws \NG\Exception * @access private * @return void */ private function _loadController() { if (!$this->_controllerLoaded) { $className = \NG\Route::getController() . "Controller"; if (class_exists($className)) { $app = new $className(); } else { \NG\Route::redirect(\NG\Uri::baseUrl() . "error/notfound", "404"); exit; } $this->_controllerLoaded = true; $method = \NG\Route::getAction() . "Action"; if (method_exists($app, $method)) { call_user_func(array($app, $method)); } else { if (DEVELOPMENT_ENVIRONMENT) { throw new \NG\Exception(sprintf('The required method "%s" does not exist for %s', $method, $className)); exit; } } } }