public function findUrlByResourceLocator($resourceLocator, $environment, $languageCode, $webspaceKey = null, $domain = null, $scheme = 'http')
{
$urls = [];
$portals = $this->getWebspaceCollection()->getPortalInformations($environment, [RequestAnalyzerInterface::MATCH_TYPE_FULL, RequestAnalyzerInterface::MATCH_TYPE_PARTIAL, RequestAnalyzerInterface::MATCH_TYPE_REDIRECT]);
foreach ($portals as $portalInformation) {
$sameLocalization = $portalInformation->getLocalization() === null || $portalInformation->getLocalization()->getLocalization() === $languageCode;
$sameWebspace = $webspaceKey === null || $portalInformation->getWebspace()->getKey() === $webspaceKey;
$url = rtrim(sprintf('%s://%s%s', $scheme, $portalInformation->getUrl(), $resourceLocator), '/');
if ($sameLocalization && $sameWebspace && $this->isFromDomain($url, $domain)) {
if ($portalInformation->isMain()) {
array_unshift($urls, $url);
} else {
$urls[] = $url;
}
}
}
return reset($urls);
}