/** * Localize given domain. * * @param string $domain * @param Localization $locale * * @return string */ protected function localizeDomain($domain, Localization $locale) { if (!$this->urlReplacer->hasLocalizationReplacer($domain) && !$this->urlReplacer->hasLanguageReplacer($domain)) { $domain = $this->urlReplacer->appendLocalizationReplacer($domain); } $domain = $this->urlReplacer->replaceLanguage($domain, $locale->getLanguage()); $domain = $this->urlReplacer->replaceCountry($domain, $locale->getCountry()); $domain = $this->urlReplacer->replaceLocalization($domain, $locale->getLocalization()); return $this->urlReplacer->cleanup($domain); }
/** * @param Portal $portal * @param Environment $environment * @param string $urlAddress * @param string $urlAnalyticsKey * @param Url $url */ private function buildUrlPartialMatch(Portal $portal, Environment $environment, $urlAddress, $urlAnalyticsKey, Url $url) { $replacers = []; $defaultSegment = $portal->getWebspace()->getDefaultSegment(); if ($defaultSegment) { $replacers[ReplacerInterface::REPLACER_SEGMENT] = $defaultSegment->getKey(); } $urlResult = $this->urlReplacer->cleanup($urlAddress, [ReplacerInterface::REPLACER_LANGUAGE, ReplacerInterface::REPLACER_COUNTRY, ReplacerInterface::REPLACER_LOCALIZATION, ReplacerInterface::REPLACER_SEGMENT]); $urlRedirect = $this->generateUrlAddress($urlAddress, $replacers); if ($this->validateUrlPartialMatch($urlResult, $environment)) { $this->portalInformations[$environment->getType()][$urlResult] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_PARTIAL, $portal->getWebspace(), $portal, null, $urlResult, $portal->getWebspace()->getDefaultSegment(), $urlRedirect, $urlAnalyticsKey, false, $url->getUrl(), $this->urlReplacer->hasHostReplacer($urlResult) ? 4 : 9); } }