コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function process(HttpRequest $request, $requestType = self::MASTER_REQUEST)
 {
     $filter = function ($result) {
         return $result instanceof HttpResponse;
     };
     try {
         $this->dispatcher->notify(new PrepareRequestEvent($request, $requestType, $this));
         $response = $this->dispatcher->publishUntil(new FilterRequestEvent($request, $requestType, $this), $filter);
         if (!$response instanceof HttpResponse) {
             $response = $this->createNotFoundResponse($request);
         }
         $event = new FilterResponseEvent($request, $requestType, $response, $this);
         $this->dispatcher->notify($event);
         $response = $event->response;
     } catch (\Exception $e) {
         if ($this->handleExceptions) {
             $response = $this->dispatcher->publishUntil(new HandleExceptionEvent($request, $requestType, $e, $this), $filter);
             if (!$response instanceof HttpResponse) {
                 throw $e;
             }
         } else {
             throw $e;
         }
     }
     $response->setProtocol($request->getProtocol());
     return $response;
 }