public function onCoreResponse(FilterResponseEvent $event)
    {
        $cms = $this->cmsSelector->retrieve();

        $response = $event->getResponse();
        $request = $event->getRequest();

        if ($this->cmsSelector->isEditor()) {
            $response->setPrivate();

            if (!$request->cookies->has('sonata_page_is_editor')) {
                $response->headers->setCookie(new Cookie('sonata_page_is_editor', '1'));
            }
        }

        $page = $cms->getCurrentPage();

        // display a validation page before redirecting, so the editor can edit the current page
        if (
            $page && $response->isRedirection() &&
            $this->cmsSelector->isEditor() &&
            !$request->get('_sonata_page_skip') &&
            !$this->skipRedirection
        ) {
            $response = new Response($this->templating->render('@SonataPage/Page/redirect.html.twig', [
                'response' => $response,
                'page' => $page,
            ]));

            $response->setPrivate();

            $event->setResponse($response);

            return;
        }

        if (!$this->decoratorStrategy->isDecorable($event->getRequest(), $event->getRequestType(), $response)) {
            return;
        }

        if (!$this->cmsSelector->isEditor() && $request->cookies->has('sonata_page_is_editor')) {
            $response->headers->clearCookie('sonata_page_is_editor');
        }

        if (!$page) {
            throw new InternalErrorException('No page instance available for the url, run the sonata:page:update-core-routes and sonata:page:create-snapshots commands');
        }

        // only decorate hybrid page or page with decorate = true
        if (!$page->isHybrid() || !$page->getDecorate()) {
            return;
        }

        $parameters = [
            'content' => $response->getContent(),
        ];

        $response = $this->pageServiceManager->execute($page, $request, $parameters, $response);

        if (!$this->cmsSelector->isEditor() && $page->isCms()) {
            $response->setTtl($page->getTtl());
        }

        $event->setResponse($response);
    }