Пример #1
0
 private function _dispatchMvcRequest()
 {
     list($controllerNamePascalCase, $actionNamePascalCase) = array(self::$_currentRoute->controller, self::$_currentRoute->action);
     $actionName = $actionNamePascalCase . 'Action';
     if ($controllerNamePascalCase == 'Controller') {
         $controllerClass = 'MvcCore_Controller';
     } else {
         $controllerClass = 'App_Controllers_' . $controllerNamePascalCase;
         $controllerFullPath = implode('/', array($this->_request->appRoot, str_replace('_', '/', $controllerClass) . '.php'));
         if (!self::$_compiled && !file_exists($controllerFullPath)) {
             return self::_dispatchException(new Exception("[MvcCore] Controller file '{$controllerFullPath}' not found."));
             // development purposes
         }
     }
     try {
         $this->_controller = new $controllerClass($this->_request);
     } catch (Exception $e) {
         return self::_dispatchException($e);
     }
     if (!method_exists($this->_controller, $actionName)) {
         return self::_dispatchException(new Exception("[MvcCore] Controller '{$controllerClass}' has not method '{$actionName}'."));
     }
     list($controllerNameDashed, $actionNameDashed) = array($this->_request->params['controller'], $this->_request->params['action']);
     try {
         $this->_controller->PreDispatch();
         $this->_controller->{$actionName}();
         $this->_controller->Render($controllerNameDashed, $actionNameDashed);
     } catch (Exception $e) {
         self::_dispatchException($e);
     }
 }
Пример #2
0
 public function AssetUrl($path = '')
 {
     return $this->Controller->AssetUrl($path);
 }