filterResponse example

return $this->lastRequest = $transformedRequest;
    }

    /** * @param Response $response */
    protected function filterResponse(object $response): DomResponse
    {
        $event = new BeforeSendResponseEvent($this->lastRequest, $response);
        $this->eventDispatcher->dispatch($event);

        return parent::filterResponse($response);
    }
}

    private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Response
    {
        // request         $event = new RequestEvent($this$request$type);
        $this->dispatcher->dispatch($event, KernelEvents::REQUEST);

        if ($event->hasResponse()) {
            return $this->filterResponse($event->getResponse()$request$type);
        }

        // load controller         if (false === $controller = $this->resolver->getController($request)) {
            throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
        }

        $event = new ControllerEvent($this$controller$request$type);
        $this->dispatcher->dispatch($event, KernelEvents::CONTROLLER);
        $controller = $event->getController();

        
if (true === $changeHistory) {
            $this->history->add($this->internalRequest);
        }

        if ($this->insulated) {
            $this->response = $this->doRequestInProcess($this->request);
        } else {
            $this->response = $this->doRequest($this->request);
        }

        $this->internalResponse = $this->filterResponse($this->response);

        $this->cookieJar->updateFromResponse($this->internalResponse, $uri);

        $status = $this->internalResponse->getStatusCode();

        if ($status >= 300 && $status < 400) {
            $this->redirect = $this->internalResponse->getHeader('Location');
        } else {
            $this->redirect = null;
        }

        

  protected function filterEmbeddedResponse(Request $fake_request, Response $embedded_response) {
    assert($embedded_response instanceof HtmlResponse || $embedded_response instanceof AjaxResponse);
    return $this->filterResponse($fake_request, HttpKernelInterface::SUB_REQUEST, $embedded_response);
  }

  /** * Filters the given response. * * @param \Symfony\Component\HttpFoundation\Request $request * The request for which a response is being sent. * @param int $request_type * The request type. Can either be * \Symfony\Component\HttpKernel\HttpKernelInterface::MAIN_REQUEST or * \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST. * @param \Symfony\Component\HttpFoundation\Response $response * The response to filter. * * @return \Symfony\Component\HttpFoundation\Response * The filtered response. */

    private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Response
    {
        // request         $event = new RequestEvent($this$request$type);
        $this->dispatcher->dispatch($event, KernelEvents::REQUEST);

        if ($event->hasResponse()) {
            return $this->filterResponse($event->getResponse()$request$type);
        }

        // load controller         if (false === $controller = $this->resolver->getController($request)) {
            throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
        }

        $event = new ControllerEvent($this$controller$request$type);
        $this->dispatcher->dispatch($event, KernelEvents::CONTROLLER);
        $controller = $event->getController();

        
Home | Imprint | This part of the site doesn't use cookies.