Ejemplo n.º 1
5
 /**
  * @param HttpRequest $httpRequest
  *
  * @return Response
  */
 public function handle(HttpRequest $httpRequest)
 {
     try {
         $routeParameters = $this->urlMatcher->matchRequest($httpRequest);
         $httpRequest->attributes->add($routeParameters);
         $request = $this->extractRequestFromRouteParameters($routeParameters);
         $controller = $this->extractControllerFromRouteParameters($routeParameters);
         return $controller->handleRequest($request, $this->serviceContainer);
     } catch (ValidationExceptionSet $exception) {
         return $this->errorResponseFactory->createBadRequestResponse($exception);
     } catch (BadRequestHttpException $exception) {
         return $this->errorResponseFactory->createBadRequestResponse($exception);
     } catch (NotFoundHttpException $exception) {
         return $this->errorResponseFactory->createNotFoundResponse($exception);
     } catch (MethodNotAllowedException $exception) {
         $exception = new MethodNotAllowedHttpException($exception->getAllowedMethods(), 'Used request method not allowed. Allowed: ' . implode(', ', $exception->getAllowedMethods()));
         return $this->errorResponseFactory->createMethodNotAllowedResponse($exception);
     } catch (\Exception $exception) {
         return $this->errorResponseFactory->createInternalServerErrorResponse($exception);
     }
 }