/** * Filter the `core.request` event to decorated the action * * @param GetResponseEvent $event * * @return void * * @throws InternalErrorException * @throws PageNotFoundException */ public function onCoreRequest(GetResponseEvent $event) { $request = $event->getRequest(); $cms = $this->cmsSelector->retrieve(); if (!$cms) { throw new InternalErrorException('No CMS Manager available'); } // true cms page if ($request->get('_route') == PageInterface::PAGE_ROUTE_CMS_NAME) { return; } if (!$this->decoratorStrategy->isRequestDecorable($request)) { return; } $site = $this->siteSelector->retrieve(); if (!$site) { throw new InternalErrorException('No site available for the current request with uri ' . htmlspecialchars($request->getUri(), ENT_QUOTES)); } if ($site->getLocale() && $site->getLocale() != $request->get('_locale')) { throw new PageNotFoundException(sprintf('Invalid locale - site.locale=%s - request._locale=%s', $site->getLocale(), $request->get('_locale'))); } try { $page = $cms->getPageByRouteName($site, $request->get('_route')); if (!$page->getEnabled() && !$this->cmsSelector->isEditor()) { throw new PageNotFoundException(sprintf('The page is not enabled : id=%s', $page->getId())); } $cms->setCurrentPage($page); } catch (PageNotFoundException $e) { return; } }