예제 #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);
     }
 }
예제 #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();
     }
 }
예제 #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;
         }
     }
 }
예제 #4
0
 /**
  * Executes the Request
  * @param \Jazz\IRequest $request
  * @param \Jazz\AResponse $response
  * @throws \Jazz\Application\Exception\MaxLoopCount
  * @precondition set the Finder in the Dispatcher
  */
 public function run(\Jazz\IRequest $request, \Jazz\AResponse $response)
 {
     $settings = $this->getSettings();
     if ($request->getApplication() === null) {
         $request->setApplication($settings->getDefaultApplication());
     }
     if ($request->getComponent() === null) {
         $request->setComponent($settings->getDefaultComponent());
     }
     if ($request->getEvent() === null) {
         $request->setEvent($settings->getDefaultEvent());
     }
     $settings->setApplication($request->getApplication());
     $settings->lock();
     $this->getFinder()->reset();
     $this->_preRun($request, $response);
     $this->dispatch($request, $response);
     $this->_postRun($request, $response);
     $ret = null;
     if ($settings->getReturnResponse()) {
         $ret = $response;
     } else {
         $response->send();
     }
     return $ret;
 }
예제 #5
0
 /**
  * Returns formatted Resource string (default as "[component.]event")
  * @param \Jazz\IRequest $request
  * @return string
  */
 protected function formatResource(\Jazz\IRequest $request)
 {
     $ret = $request->getEvent();
     if ($request->getComponent() !== null) {
         $ret = $request->getComponent() . '.' . $ret;
     }
     return $ret;
 }