Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getLanguageToDomainMapping example
return
new
HreflangCollection
(
)
;
}
$domains
=
$this
->
fetchSalesChannelDomains
(
$salesChannelContext
->
getSalesChannel
(
)
->
getId
(
)
)
;
if
(
$parameter
->
getRoute
(
)
=== 'frontend.home.page'
)
{
return
$this
->
getHreflangForHomepage
(
$domains
,
$salesChannelContext
->
getSalesChannel
(
)
->
getHreflangDefaultDomainId
(
)
)
;
}
$pathInfo
=
$this
->router->
generate
(
$parameter
->
getRoute
(
)
,
$parameter
->
getRouteParameters
(
)
, RouterInterface::ABSOLUTE_PATH
)
;
$languageToDomainMapping
=
$this
->
getLanguageToDomainMapping
(
$domains
)
;
$seoUrls
=
$this
->
fetchSeoUrls
(
$pathInfo
,
$salesChannelContext
->
getSalesChannel
(
)
->
getId
(
)
,
array_keys
(
$languageToDomainMapping
)
)
;
// We need at least two links
if
(
\
count
(
$seoUrls
)
<= 1
)
{
return
new
HreflangCollection
(
)
;
}
$hreflangCollection
=
new
HreflangCollection
(
)
;
/** @var array{seoPathInfo: string, languageId: string} $seoUrl */
foreach
(
$seoUrls
as
$seoUrl
)
{