Creates the Response from the view.

@param View   $view
@param string $location
@param string $format

@return Response
194811
public function createRedirectResponse(View $view, $location, $format)
    {
        $content = null;
        if ((Response::HTTP_CREATED === $view->getStatusCode() || Response::HTTP_ACCEPTED === $view->getStatusCode()) && null !== $view->getData()) {
            $response = $this->initResponse($view, $format);
        } else {
            $response = $view->getResponse();
            if ('html' === $format && isset($this->forceRedirects[$format])) {
                $redirect = new RedirectResponse($location);
                $content = $redirect->getContent();
                $response->setContent($content);
            }
        }

        $code = isset($this->forceRedirects[$format])
            ? $this->forceRedirects[$format] : $this->getStatusCode($view, $content);

        $response->setStatusCode($code);
        $response->headers->set('Location', $location);

        return $response;
    }
219511
public function previewAction(
        Content $content,
        ?string $languageCode = null,
        ?int $versionNo = null,
        ?Location $location = null
    ): Response {
        if (null === $languageCode) {
            $languageCode = $content->contentInfo->mainLanguageCode;
        }

        // nonpublished content should use parent location instead because location doesn't exist yet
        if (!$content->contentInfo->published && null === $content->contentInfo->mainLocationId) {
            $versionInfo = $this->contentService->loadVersionInfo($content->contentInfo, $versionNo);
            $parentLocations = $this->locationService->loadParentLocationsForDraftContent($versionInfo);
            $location = reset($parentLocations);
            $versionNo = null;
        }

        if (null === $location) {
            $location = $this->locationService->loadLocation($content->contentInfo->mainLocationId);
        }

        $siteaccesses = $this->siteaccessResolver->getSiteaccessesForLocation($location, $versionNo, $languageCode);

        if (empty($siteaccesses)) {
            throw new BadStateException(
                'siteaccess',
                'There is no siteaccesses available for particular content'
            );
        }

        return $this->render('@ezdesign/content/content_preview.html.twig', [
            'location' => $location,
            'content' => $content,
            'language_code' => $languageCode,
            'siteaccesses' => $siteaccesses,
            'versionNo' => $versionNo ?? $content->getVersionInfo()->versionNo,
        ]);
    }
125226
private function createCustomUrlAddForm(Location $location): FormInterface
    {
        $customUrlAddData = new CustomUrlAddData($location);

        return $this->formFactory->addCustomUrl($customUrlAddData);
    }
18080
public function view($view, $data = [], $mergeData = [])
    {
        return $this->response(View::make($view, $data, $mergeData));
    }
869802
public function renderTemplate(View $view, $format)
    {
        if (null === $this->templating) {
            throw new \LogicException(sprintf('An instance of %s must be injected in %s to render templates.', EngineInterface::class, __CLASS__));
        }

        $data = $this->prepareTemplateParameters($view);

        $template = $view->getTemplate();
        if ($template instanceof TemplateReferenceInterface) {
            if (null === $template->get('format')) {
                $template->set('format', $format);
            }

            if (null === $template->get('engine')) {
                $engine = $view->getEngine() ?: $this->defaultEngine;
                $template->set('engine', $engine);
            }
        }

        return $this->templating->render($template, $data);
    }
128241
public function render($view, array $parameters = [], Response $response = null)
    {
        $parameters['media_pool'] = $this->get('sonata.media.pool');
        $parameters['persistent_parameters'] = $this->admin->getPersistentParameters();

        return parent::renderWithExtraParams($view, $parameters, $response);
    }
485207
public function createView(View $view)
    {
        $this->_execSql($this->_platform->getCreateViewSQL($view->getQuotedName($this->_platform), $view->getSql()));
    }
262830
public function performRequest($urlSuffix = null, $method = 'GET',
                                   $format = null)
    {
        $this->rowCount      = null;
        $this->responseStats = [];

        if (preg_match('/^http/', $urlSuffix)) {
            $url = $urlSuffix;
        } elseif (strlen($urlSuffix) && ($urlSuffix[0] == '/')) {
            $url = $this->url.$urlSuffix;
        } else {
            $url = $this->evidenceUrlWithSuffix($urlSuffix);
        }

        $responseCode = $this->doCurlRequest($this->addDefaultUrlParams($url),
            $method, $format);

        return $this->parseResponse($this->rawResponseToArray($this->lastCurlResponse,
                    $this->responseFormat), $responseCode);
    }
439923
public static function create($template = null, $view = '', $viewdata = [], $status = 200, $headers = array())
    {
        if (!$template instanceof TemplateEngineInterface) {
            throw new InvalidArgumentException('The first argument of ViewResponse::create must be an instance of Laasti\Response\Engines\TemplateEngineInterface');
        }
        return new static($template, $view, $viewdata, $status, $headers);
    }
826989
public function createAction(Request $request, $provider = 'image')
    {
        $dispatcher = $this->get('event_dispatcher');
        $event = new ResponseEvent($request);
        $dispatcher->dispatch(OpiferMediaEvents::MEDIA_CONTROLLER_NEW, $event);

        if (null !== $event->getResponse()) {
            return $event->getResponse();
        }

        $mediaManager = $this->get('opifer.media.media_manager');
        $mediaProvider = $this->get('opifer.media.provider.pool')->getProvider($provider);

        $media = $mediaManager->createMedia();

        $form = $this->createForm(MediaType::class, $media, ['provider' => $mediaProvider]);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $mediaManager->save($media);

            $this->addFlash('success', sprintf('%s was succesfully created', $media->getName()));

            return $this->redirectToRoute('opifer_media_media_index');
        }

        return $this->render($this->container->getParameter('opifer_media.media_create_view'), [
            'form' => $form->createView(),
            'provider' => $mediaProvider,
        ]);
    }
980246
public function composeError($view, array $data = [], int $status = 404): Response
    {
        $engine = $this->view;
        $file = "errors.{$status}";
        $view = $engine->exists($file) ? $engine->make($file, $data) : "{$status} Error";

        return new Response($view, $status);
    }
1057647
public function retrieve($view, $viewId, $viewLocale)
    {
        if (ConfigQuery::isRewritingEnable()) {
            $this->retriever->loadViewUrl($view, $viewLocale, $viewId);
        } else {
            $allParametersWithoutView = array();
            $allParametersWithoutView['lang'] = $viewLocale;
            if (null !== $viewId) {
                $allParametersWithoutView[$view . '_id'] = $viewId;
            }
            $this->retriever->rewrittenUrl = null;
            $this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
        }

        return $this->retriever;
    }
920611
public function renderResponse($view, array $parameters = array(), Response $response = null)
    {
        if (null === $response) {
            $response = new Response();
        }

        $response->setContent($this->render($view, $parameters));

        return $response;
    }
98581
public function editAction(Location $location, Request $request)
    {
        if ($location->getProfile()->getId() != $this->getCurrentProfile()->getId())
        {
            throw new \Exception('No access to this Location');
        }

        $form = $this->createForm(new LocationType(), $location);

        if ($response = $this->processForm($request, $form, 'Profile_location_show'))
        {
            return $response;
        }

        return $this->render('HarvestCloudCoreBundle:Profile/Location:edit.html.twig', array(
          'form'     => $form->createView(),
          'location' => $location,
        ));
    }
832383
protected function checkCategoryRedirect(Location $location): ?RedirectResponse
    {
        $content = $location->content;

        $internalRedirectContent = null;
        if (!$content->getField('internal_redirect')->isEmpty()) {
            $internalRedirectContent = $content->getFieldRelation('internal_redirect');
        }

        $externalRedirectValue = $content->getField('external_redirect')->value;

        if ($internalRedirectContent instanceof Content) {
            if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
                return new RedirectResponse(
                    $this->router->generate($internalRedirectContent),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        } elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
            if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
                return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
            }

            return new RedirectResponse(
                $this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
                RedirectResponse::HTTP_MOVED_PERMANENTLY
            );
        }

        return null;
    }
616241
public static function createRedirectResponse(string $location): ResponseInterface
    {
        if (empty($location)) {

            throw new InvalidArgumentException("Location header value cannot be empty");

        }

        $response = new Response(302);
        return $response->withHeader("Location", $location);
    }
824726
public static function dateSQL($date, $format = 'd-m-Y')
    {
        if (empty($date)) {
            return null;
        }

        $obj = DateTime::createFromFormat('Y-m-d H:i:s', $date);
        if (empty($obj)) {
            return null;
        }

        return $obj->format($format);
    }