CodeExplorer HrefLang example
if (\
count($shops) === 1
) { return [];
} $hrefs =
[];
foreach ($shops as $languageShop) { $shop =
$this->
getDetachedShop($languageShop['id'
]);
$config->
setShop($shop);
$href =
new HrefLang();
$href->
setShopId($languageShop['id'
]);
$href->
setLocale($languageShop['locale'
]);
$routingContext =
$this->
getContext($shop,
$config);
$href->
setLink($this->
filterUrl((string) $this->rewriteRouter->
assemble($parameters,
$routingContext),
$parameters));
if (!
$config->
get('hrefLangCountry'
)) { $href->
setLocale(explode('-',
$languageShop['locale'
])[0
]);
} if ((int) $languageShop['id'
] ===
$config->
get('hrefLangDefaultShop'
)) { $href->
setLocale('x-default'
);
}