Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
HreflangCollection example
public
function
__construct
(
private
readonly RouterInterface
$router
,
private
readonly Connection
$connection
)
{
}
public
function
load
(
HreflangLoaderParameter
$parameter
)
: HreflangCollection
{
$salesChannelContext
=
$parameter
->
getSalesChannelContext
(
)
;
if
(
!
$salesChannelContext
->
getSalesChannel
(
)
->
isHreflangActive
(
)
)
{
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
)
;