/** * {@inheritdoc} */ public function process(Request $request, RequestAttributes $requestAttributes) { $host = $request->getHttpHost(); $url = $host . $request->getPathInfo(); foreach ($this->webspaceManager->getPortalInformations($this->environment) as $portalInformation) { $portalUrl = $this->replacer->replaceHost($portalInformation->getUrl(), $host); $portalInformation->setUrl($portalUrl); $portalRedirect = $this->replacer->replaceHost($portalInformation->getRedirect(), $host); $portalInformation->setRedirect($portalRedirect); } $portalInformations = $this->webspaceManager->findPortalInformationsByUrl($url, $this->environment); if (count($portalInformations) === 0) { return new RequestAttributes(); } usort($portalInformations, function (PortalInformation $a, PortalInformation $b) { if ($a->getPriority() === $b->getPriority()) { return strlen($a->getUrl()) < strlen($b->getUrl()); } return $a->getPriority() < $b->getPriority(); }); /** @var PortalInformation $portalInformation */ $portalInformation = reset($portalInformations); return new RequestAttributes(['portalInformation' => $portalInformation]); }
/** * {@inheritdoc} */ public function invalidatePath($path, array $headers = []) { $path = $this->requestHost ? $this->replacer->replaceHost($path, $this->requestHost) : $path; $this->pathsToInvalidate[] = ['path' => $path, 'headers' => $headers]; }