Returns all possible urls for resourcelocator.
public findUrlsByResourceLocator ( string $resourceLocator, string $environment, string $languageCode, null | string $webspaceKey = null, null | string $domain = null, string $scheme = 'http' ) : array | ||
$resourceLocator | string | |
$environment | string | |
$languageCode | string | |
$webspaceKey | null | string | |
$domain | null | string | |
$scheme | string | |
return | array |
/** * {@inheritdoc} */ public function handle($workload) { /** @var PageDocument $document */ $document = $this->documentManager->find($workload['uuid'], $workload['locale']); $urls = $this->webspaceManager->findUrlsByResourceLocator($document->getResourceSegment(), $this->environment, $workload['locale'], $workload['webspaceKey']); foreach ($urls as $url) { $this->client->get($url)->send(); } }
/** * {@inheritdoc} */ public function getContentPath($url, $webspaceKey = null, $locale = null, $domain = null) { if ($webspaceKey !== null && $this->requestAnalyzer) { $portalUrls = $this->webspaceManager->findUrlsByResourceLocator($url, $this->environment, $locale ?: $this->requestAnalyzer->getCurrentLocalization()->getLocalization(), $webspaceKey, $domain); if (count($portalUrls) > 0) { return rtrim($portalUrls[0], '/'); } } elseif (strpos($url, '/') === 0 && $this->requestAnalyzer) { return rtrim($this->requestAnalyzer->getResourceLocatorPrefix() . $url, '/'); } return $url; }
/** * {@inheritdoc} */ public function sitemapUrlFunction($url, $locale = null, $webspaceKey = null) { if ($webspaceKey === null) { $webspaceKey = $this->requestAnalyzer->getWebspace()->getKey(); } if ($locale === null) { $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization(); } // FIXME which url or all urls? $portalUrls = $this->webspaceManager->findUrlsByResourceLocator($url, $this->environment, $locale, $webspaceKey); if (sizeof($portalUrls) === 0) { return false; } return rtrim($portalUrls[0], '/'); }
/** * Returns all urls of the given locale which are associated with the given document. * The returned array contains all current urls and all history urls. * The returned urls can contain placeholders (eg {host}). * * @param ResourceSegmentBehavior $document * @param string $locale * * @return array Urls of the given locale which are associated with the given document */ private function getLocaleUrls(ResourceSegmentBehavior $document, $locale) { $documentUuid = $document instanceof UuidBehavior ? $document->getUuid() : null; $webspace = $document instanceof WebspaceBehavior ? $document->getWebspaceName() : null; if (!$locale || !$documentUuid || !$webspace) { return []; } $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspace); // get current resource-locator and history resource-locators $resourceLocators = []; try { $resourceLocators[] = $resourceLocatorStrategy->loadByContentUuid($documentUuid, $webspace, $locale); } catch (ResourceLocatorNotFoundException $e) { // if no resource locator exists there is also no url to purge from the cache } $historyResourceLocators = $resourceLocatorStrategy->loadHistoryByContentUuid($documentUuid, $webspace, $locale); foreach ($historyResourceLocators as $historyResourceLocator) { $resourceLocators[] = $historyResourceLocator->getResourceLocator(); } // get urls for resource-locators $urls = []; foreach ($resourceLocators as $resourceLocator) { $urls = array_merge($urls, $this->webspaceManager->findUrlsByResourceLocator($resourceLocator, $this->environment, $locale, $webspace)); } return $urls; }
/** * {@inheritDoc} */ public function flush() { if (!$this->structuresToInvalidate) { return; } foreach ($this->structuresToInvalidate as $structure) { if (false === $structure->hasTag('sulu.rlp') || null === ($rlp = $structure->getPropertyValueByTagName('sulu.rlp'))) { return; } $urls = $this->webspaceManager->findUrlsByResourceLocator($rlp, $this->environment, $structure->getLanguageCode(), $structure->getWebspaceKey()); foreach ($urls as $url) { $this->proxyClient->purge($url); } } $this->proxyClient->flush(); }