/** * @return IPresenterResponse */ public function run(NPresenterRequest $request) { try { // STARTUP $this->request = $request; $this->payload = new stdClass; $this->setParent($this->getParent(), $request->getPresenterName()); $this->initGlobalParameters(); $this->checkRequirements($this->getReflection()); $this->startup(); if (!$this->startupCheck) { $class = $this->getReflection()->getMethod('startup')->getDeclaringClass()->getName(); throw new InvalidStateException("Method $class::startup() or its descendant doesn't call parent::startup()."); } // calls $this->action<Action>() $this->tryCall($this->formatActionMethod($this->getAction()), $this->params); if ($this->autoCanonicalize) { $this->canonicalize(); } if ($this->getHttpRequest()->isMethod('head')) { $this->terminate(); } // SIGNAL HANDLING // calls $this->handle<Signal>() $this->processSignal(); // RENDERING VIEW $this->beforeRender(); // calls $this->render<View>() $this->tryCall($this->formatRenderMethod($this->getView()), $this->params); $this->afterRender(); // save component tree persistent state $this->saveGlobalState(); if ($this->isAjax()) { $this->payload->state = $this->getGlobalState(); } // finish template rendering $this->sendTemplate(); } catch (NAbortException $e) { // continue with shutting down if ($this->isAjax()) try { $hasPayload = (array) $this->payload; unset($hasPayload['state']); if ($this->response instanceof NTextResponse && $this->isControlInvalid()) { // snippets - TODO $this->snippetMode = TRUE; $this->response->send($this->getHttpRequest(), $this->getHttpResponse()); $this->sendPayload(); } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload() $this->sendPayload(); } } catch (NAbortException $e) { } if ($this->hasFlashSession()) { $this->getFlashSession()->setExpiration($this->response instanceof NRedirectResponse ? '+ 30 seconds' : '+ 3 seconds'); } // SHUTDOWN $this->onShutdown($this, $this->response); $this->shutdown($this->response); return $this->response; } }
/** * @param PresenterRequest * @return IPresenterResponse */ public function run(PresenterRequest $request) { try { // STARTUP $this->request = $request; $this->payload = (object) NULL; $this->setParent($this->getParent(), $request->getPresenterName()); $this->initGlobalParams(); $this->startup(); if (!$this->startupCheck) { $class = $this->reflection->getMethod('startup')->getDeclaringClass()->getName(); trigger_error("Method {$class}::startup() or its descendant doesn't call parent::startup().", E_USER_WARNING); } // calls $this->action<Action>() $this->tryCall($this->formatActionMethod($this->getAction()), $this->params); if ($this->autoCanonicalize) { $this->canonicalize(); } if ($this->getHttpRequest()->isMethod('head')) { $this->terminate(); } // SIGNAL HANDLING // calls $this->handle<Signal>() $this->processSignal(); // RENDERING VIEW $this->beforeRender(); // calls $this->render<View>() $this->tryCall($this->formatRenderMethod($this->getView()), $this->params); $this->afterRender(); // save component tree persistent state $this->saveGlobalState(); if ($this->isAjax()) { $this->payload->state = $this->getGlobalState(); } // finish template rendering $this->sendTemplate(); } catch (AbortException $e) { // continue with shutting down } if ($this->isAjax()) { try { $hasPayload = (array) $this->payload; unset($hasPayload['state']); if ($this->response instanceof RenderResponse && ($this->isControlInvalid() || $hasPayload)) { // snippets - TODO SnippetHelper::$outputAllowed = FALSE; $this->response->send(); $this->sendPayload(); } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload() $this->sendPayload(); } } catch (AbortException $e) { } } if ($this->hasFlashSession()) { $this->getFlashSession()->setExpiration($this->response instanceof RedirectingResponse ? '+ 30 seconds' : '+ 3 seconds'); } // SHUTDOWN $this->onShutdown($this, $this->response); $this->shutdown($this->response); return $this->response; }