/** * Handles creation of a Response using either redirection or the templating/serializer service. * * @param View $view * @param Request $request * @param string $format * * @return Response */ public function createResponse(View $view, Request $request, $format) { $route = $view->getRoute(); $location = $route ? $this->urlGenerator->generate($route, (array) $view->getRouteParameters(), UrlGeneratorInterface::ABSOLUTE_URL) : $view->getLocation(); if ($location) { return $this->createRedirectResponse($view, $location, $format); } $response = $this->initResponse($view, $format); if (!$response->headers->has('Content-Type')) { $response->headers->set('Content-Type', $request->getMimeType($format)); } return $response; }