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); } } }
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; }
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(); }
static function getLocalesReady() { Ak::t('Akelos'); AK_ENABLE_PROFILER && AkDebug::profile('Got multilingual '); }
/** * @deprecated * @uses AkDebug::profile */ static function profile($message = '') { Ak::deprecateMethod(__METHOD__, 'AkConfig::profile()'); return AkDebug::profile($message); }