/** * {@inheritdoc} */ public function dumpPortalInformation(PortalInformation $portalInformation, $scheme) { if (false !== strpos($portalInformation->getUrl(), '{host}')) { if (!$this->defaultHost) { return; } $portalInformation->setUrl(str_replace('{host}', $this->defaultHost, $portalInformation->getUrl())); } $dumpPath = $this->getIndexDumpPath($scheme, $portalInformation->getWebspaceKey(), $portalInformation->getLocale(), $portalInformation->getHost()); $sitemap = $this->sitemapRenderer->renderIndex($portalInformation->getHost(), $scheme); if (!$sitemap) { $aliases = array_keys($this->sitemapProviderPool->getProviders()); $this->dumpFile($dumpPath, $this->sitemapRenderer->renderSitemap(reset($aliases), 1, $portalInformation->getLocale(), $portalInformation->getPortal(), $portalInformation->getHost(), $scheme)); return; } foreach ($this->sitemapProviderPool->getProviders() as $alias => $provider) { $this->dumpProviderSitemap($alias, $portalInformation, $scheme); } $this->dumpFile($dumpPath, $sitemap); }
/** * 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]; }