Пример #1
0
 /**
  * getRequests()
  * Returns requests
  * @access public
  * @return array
  */
 public static function getRequests()
 {
     self::determineRoute();
     if (!self::init()->request) {
         $path = \NG\Uri::init()->getPathArray();
         if (is_array($path) and !empty($path)) {
             foreach (array_slice($path, 1) as $key => $value) {
                 self::init()->setRequest($key, $value);
             }
         }
     }
     return self::init()->request;
 }
Пример #2
0
 /**
  * _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;
             }
         }
     }
 }