public static function dieOnRoute($route) { ob_get_clean(); // We start a mini app here to display the route // Copied from Ajde_Application $route = new Route($route); $document = Document::fromRoute($route); // replace document in Ajde_Application Ajde::app()->setDocument($document); // replace route in Ajde_Application Ajde::app()->setRoute($route); $controller = Controller::fromRoute($route); $actionResult = $controller->invoke(); $document->setBody($actionResult); if (!$document->hasLayout()) { $layout = new Layout(Config::get("layout")); $document->setLayout($layout); } echo $document->render(); die; }
public function run() { // For debugger $this->addTimer('<i>Application</i>'); // Create fresh response $timer = $this->addTimer('Create response'); $response = new Response(); $this->setResponse($response); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterResponseCreated'); // Bootstrap init $timer = $this->addTimer('Run bootstrap queue'); $bootstrap = new Bootstrap(); $bootstrap->run(); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterBootstrap'); // Get request $timer = $this->addTimer('Read in global request'); $request = Request::fromGlobal(); $this->setRequest($request); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterRequestCreated'); // Get route $timer = $this->addTimer('Initialize route'); $route = $request->initRoute(); $this->setRoute($route); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterRouteInitialized'); // Load document $timer = $this->addTimer('Create document'); $document = Document::fromRoute($route); $this->setDocument($document); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterDocumentCreated'); // Load controller $timer = $this->addTimer('Load controller'); $controller = Controller::fromRoute($route); $this->setController($controller); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterControllerCreated'); // Invoke controller action $timer = $this->addTimer('Invoke controller'); $actionResult = $controller->invoke(); $document->setBody($actionResult); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterControllerInvoked'); // Get document contents $timer = $this->addTimer('Render document'); $contents = $document->render(); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterDocumentRendered'); // Let the cache handle the contents and have it saved to the response $timer = $this->addTimer('Save to response'); $cache = Cache::getInstance(); $cache->setContents($contents); $cache->saveResponse(); $this->endTimer($timer); Dispatcher::trigger($this, 'onAfterResponseCreated'); // Output the buffer $response->send(); Dispatcher::trigger($this, 'onAfterResponseSent'); }