/** * Matches given url to portal-information. * * @param string $url * @param PortalInformation $portalInformation * @param Request $request * * @return RequestAttributes|void */ private function matchCustomUrl($url, PortalInformation $portalInformation, Request $request) { $webspace = $portalInformation->getWebspace(); $routeDocument = $this->customUrlManager->findRouteByUrl($url, $webspace->getKey()); if (!$routeDocument) { return []; } elseif ($routeDocument->isHistory()) { // redirect happen => no portal is needed return ['customUrlRoute' => $routeDocument]; } $customUrlDocument = $this->customUrlManager->findByUrl($url, $webspace->getKey(), $routeDocument->getTargetDocument()->getTargetLocale()); if ($customUrlDocument === null || $customUrlDocument->isPublished() === false || $customUrlDocument->getTargetDocument() === null || $customUrlDocument->getTargetDocument()->getWorkflowStage() !== WorkflowStage::PUBLISHED) { // error happen because this custom-url is not published => no portal is needed return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument]; } $localization = $this->parse($customUrlDocument->getTargetLocale()); $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($portalInformation->getWebspace()->getKey(), $localization->getLocalization(), $this->environment); if (0 === count($portalInformations)) { return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument]; } return ['portalInformation' => $portalInformation, 'localization' => $localization, 'customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument, 'urlExpression' => $this->generator->generate($customUrlDocument->getBaseDomain(), $customUrlDocument->getDomainParts())]; }