예제 #1
0
파일: dispatcher.php 프로젝트: bermi/akelos
 public function dispatchAppServer($context)
 {
     $_ENV = $_SERVER = $context['env'];
     @parse_str($_ENV['QUERY_STRING'], $_GET);
     $_GET['ak'] = $_ENV['PATH_INFO'];
     Ak::unsetStaticVar('AkRequestSingleton');
     Ak::unsetStaticVar('AkRouterSingleton');
     Ak::unsetStaticVar('AkUrlWriterSingleton');
     AkConfig::setOption('Request.remote_ip', '127.0.0.1');
     try {
         $time_start = microtime(true);
         AK_ENABLE_PROFILER && AkDebug::profile(__CLASS__ . '::' . __FUNCTION__ . '() call');
         $this->Request = AkRequest::getInstance();
         $this->Response = new AkResponse();
         $path = ltrim(str_replace('..', '.', $context['env']['REQUEST_URI']), '/. ');
         if (empty($path) && file_exists(AK_PUBLIC_DIR . DS . 'index.html')) {
             $Controller = new AkActionController();
             $Controller->Response = $this->Response;
             $Controller->renderText(file_get_contents(AK_PUBLIC_DIR . DS . 'index.html'));
             return $Controller->Response;
         } elseif (!empty($path) && file_exists(AK_PUBLIC_DIR . DS . $path)) {
             $Controller = new AkActionController();
             $Controller->Response = $this->Response;
             $Controller->sendFile(AK_PUBLIC_DIR . DS . $path, array('stream' => false));
             return $Controller->Response;
         } else {
             if ($this->Controller = $this->Request->recognize()) {
                 $this->Controller->ak_time_start = $time_start;
                 AK_ENABLE_PROFILER && AkDebug::profile('Request::recognize() completed');
                 $this->Controller->process($this->Request, $this->Response);
             }
             return $this->Response;
         }
     } catch (Exception $e) {
         if (isset($this->Controller) && method_exists($this->Controller, 'render_error')) {
             $this->Controller->render_error($e);
         } else {
             $ExceptionDispatcher = new AkExceptionDispatcher();
             $ExceptionDispatcher->renderException($e);
         }
     }
 }
예제 #2
0
 public function performActionWithFilters($method = '')
 {
     if ($this->beforeAction($method) !== false && !empty($this->_FilteredObject) && method_exists($this->_FilteredObject, 'hasPerformed') && !$this->_FilteredObject->hasPerformed()) {
         if (AK_ENABLE_PROFILER) {
             AkDebug::profile("Called {$method}  before filters");
         }
         $this->_FilteredObject->performActionWithoutFilters($method);
         if (AK_ENABLE_PROFILER) {
             AkDebug::profile("Performed {$method}  action");
         }
         $this->afterAction($method);
         if (AK_ENABLE_PROFILER) {
             AkDebug::profile("Called {$method}  after filters");
         }
         return true;
     }
     return false;
 }
예제 #3
0
 public function process(&$Request, &$Response, $options = array())
 {
     if (AK_ENABLE_PROFILER) {
         AkDebug::profile('AkActionController::process() start');
     }
     $this->setRequestAndResponse($Request, $Response);
     if (AK_LOG_EVENTS) {
         $this->_logRequestParams($this->params);
     }
     if (AK_ENABLE_PROFILER) {
         AkDebug::profile('Got request paramenters');
     }
     $actionExists = $this->_ensureActionExists();
     if (!$actionExists) {
         $this->handleResponse();
         return false;
     }
     AkConfig::getLocalesReady();
     if ($this->_high_load_mode !== true) {
         if (!empty($this->_auto_instantiate_models)) {
             $this->instantiateIncludedModelClasses();
             if (AK_ENABLE_PROFILER) {
                 AkDebug::profile('Instantiated models');
             }
         }
         if (!empty($this->_enable_plugins)) {
             $this->loadPlugins();
             if (AK_ENABLE_PROFILER) {
                 AkDebug::profile('Instantiated plugins');
             }
         }
     }
     $this->_ensureProperProtocol();
     $this->_lazy_loading_options = $options;
     //$this->init($options);
     // After filters
     //$this->isFilteringActive() && $this->afterFilter('_handleFlashAttribute');
     $this->_loadActionView();
     if (isset($this->api)) {
         $this->aroundFilter(new AkActionWebService($this));
     }
     $this->_identifyRequest();
     if ($this->isFilteringActive()) {
         $this->performActionWithFilters($this->_action_name);
     } else {
         $this->performActionWithoutFilters($this->_action_name);
     }
     return $this->handleResponse();
 }
예제 #4
0
파일: base.php 프로젝트: bermi/akelos
 static function getLocalesReady()
 {
     Ak::t('Akelos');
     AK_ENABLE_PROFILER && AkDebug::profile('Got multilingual ');
 }
예제 #5
0
파일: base.php 프로젝트: bermi/akelos
 /**
  * @deprecated
  * @uses AkDebug::profile
  */
 static function profile($message = '')
 {
     Ak::deprecateMethod(__METHOD__, 'AkConfig::profile()');
     return AkDebug::profile($message);
 }