示例#1
0
 public function run()
 {
     // For debugger
     $this->addTimer('<i>Application</i>');
     // Create fresh response
     $timer = $this->addTimer('Create response');
     $response = new Ajde_Http_Response();
     $this->setResponse($response);
     $this->endTimer($timer);
     // Bootstrap init
     $timer = $this->addTimer('Run bootstrap cue');
     $bootstrap = new Ajde_Core_Bootstrap();
     $bootstrap->run();
     $this->endTimer($timer);
     // Get request
     $timer = $this->addTimer('Read in global request');
     $request = Ajde_Http_Request::fromGlobal();
     $this->setRequest($request);
     $this->endTimer($timer);
     // Get route
     $timer = $this->addTimer('Initialize route');
     $route = $request->initRoute();
     $this->setRoute($route);
     $this->endTimer($timer);
     // Load document
     $timer = $this->addTimer('Create document');
     $document = Ajde_Document::fromRoute($route);
     $this->setDocument($document);
     $this->endTimer($timer);
     // Load controller
     $timer = $this->addTimer('Load controller');
     $controller = Ajde_Controller::fromRoute($route);
     $this->setController($controller);
     $this->endTimer($timer);
     // Invoke controller action
     $timer = $this->addTimer('Invoke controller');
     $actionResult = $controller->invoke();
     $document->setBody($actionResult);
     $this->endTimer($timer);
     // Get document contents
     $timer = $this->addTimer('Render document');
     $contents = $document->render();
     $this->endTimer($timer);
     // Let the cache handle the contents and have it saved to the response
     $timer = $this->addTimer('Save to response');
     $cache = Ajde_Cache::getInstance();
     $cache->setContents($contents);
     $cache->saveResponse();
     $this->endTimer($timer);
     // Output the buffer
     $response->send();
 }
示例#2
0
 public static function dieOnRoute($route)
 {
     ob_get_clean();
     // We start a mini app here to display the route
     // Copied from Ajde_Application
     $route = new Ajde_Core_Route($route);
     $document = Ajde_Document::fromRoute($route);
     // replace document in Ajde_Application
     Ajde::app()->setDocument($document);
     $controller = Ajde_Controller::fromRoute($route);
     $actionResult = $controller->invoke();
     $document->setBody($actionResult);
     if (!$document->hasLayout()) {
         $layout = new Ajde_Layout(Config::get("layout"));
         $document->setLayout($layout);
     }
     echo $document->render();
     die;
 }