/** * Returns resource locator and format of current request. * * @param PortalInformation $portalInformation * @param Request $request * * @return array */ private function getResourceLocatorFromRequest(PortalInformation $portalInformation, Request $request) { $path = $request->getPathInfo(); // extract file and extension info $pathParts = explode('/', $path); $fileInfo = explode('.', array_pop($pathParts)); $path = rtrim(implode('/', $pathParts), '/') . '/' . $fileInfo[0]; $formatResult = null; if (count($fileInfo) > 1) { $formatResult = end($fileInfo); } $resourceLocator = substr($request->getHttpHost() . $path, strlen($portalInformation->getUrl())); return [$resourceLocator, $formatResult]; }
/** * Render sitemap for provider. * * @param string $alias * @param PortalInformation $portalInformation * @param string $scheme */ private function dumpProviderSitemap($alias, PortalInformation $portalInformation, $scheme) { $maxPage = $this->sitemapProviderPool->getProvider($alias)->getMaxPage(); for ($page = 1; $page <= $maxPage; ++$page) { $sitemap = $this->sitemapRenderer->renderSitemap($alias, $page, $portalInformation->getLocale(), $portalInformation->getPortal(), $portalInformation->getHost(), $scheme); $this->dumpFile($this->getDumpPath($scheme, $portalInformation->getWebspaceKey(), $portalInformation->getLocale(), $portalInformation->getHost(), $alias, $page), $sitemap); } }
/** * 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())]; }