Exemplo n.º 1
0
 /**
  * Dispatch Loop Shutdown
  * @param \Jazz\IRequest $request
  * @param \Jazz\AResponse $response
  */
 public function stopDispatch(\Jazz\IRequest $request, \Jazz\AResponse $response)
 {
     $type = $this->getMimeType($request->getContentType());
     if ($type !== null) {
         $response->setHeader('Content-Type', $type);
     }
 }
Exemplo n.º 2
0
 /**
  * Handles any Errors
  * @param \Jazz\IRequest $request
  * @param \Jazz\AResponse $response
  */
 protected function handleError(\Jazz\IRequest $request, \Jazz\AResponse $response)
 {
     if ($response->hasExceptions()) {
         $request->set('errors', $response->getExceptions());
         $request->setComponent($this->getComponent());
         $request->setEvent($this->getEvent());
         $request->setRun(false);
         $response->clearExceptions();
     }
 }
Exemplo n.º 3
0
 /**
  * Dispatch Loop Shutdown
  * @param \Jazz\IRequest $request
  * @param \Jazz\AResponse $response
  * @throws \Exception
  */
 public function stopDispatch(\Jazz\IRequest $request, \Jazz\AResponse $response)
 {
     $layout = $this->getLayout();
     if ($request->hasRun() && !$response->isRedirect() && $layout->isEnabled()) {
         $content = $response->get();
         $key = $layout->getKey();
         if (array_key_exists('default', $content)) {
             $content[$key] = $content['default'];
         }
         if ($key != 'default') {
             unset($content['default']);
         }
         $layout->assign($key, $content[$key]);
         try {
             $response->set($layout->render());
         } catch (\Exception $e) {
             $response->set(null);
             throw $e;
         }
     }
 }