Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
mergeStaticConfig example
$theme
=
$themes
->
get
(
$themeId
)
;
if
(
$theme
=== null
)
{
throw
new
InvalidThemeException
(
$themeId
)
;
}
$baseTheme
=
$themes
->
filter
(
fn
(
ThemeEntity
$themeEntry
)
=>
$themeEntry
->
getTechnicalName
(
)
=== StorefrontPluginRegistry::BASE_THEME_NAME
)
->
first
(
)
;
if
(
$baseTheme
=== null
)
{
throw
new
InvalidThemeException
(
StorefrontPluginRegistry::BASE_THEME_NAME
)
;
}
$baseThemeConfig
=
$this
->
mergeStaticConfig
(
$baseTheme
)
;
$themeConfigFieldFactory
=
new
ThemeConfigFieldFactory
(
)
;
$configFields
=
[
]
;
$labels
=
array_replace_recursive
(
$baseTheme
->
getLabels
(
)
??
[
]
,
$theme
->
getLabels
(
)
??
[
]
)
;
$helpTexts
=
array_replace_recursive
(
$baseTheme
->
getHelpTexts
(
)
??
[
]
,
$theme
->
getHelpTexts
(
)
??
[
]
)
;
if
(
$theme
->
getParentThemeId
(
)
)
{
foreach
(
$this
->
getParentThemes
(
$themes
,
$theme
)
as
$parentTheme
)
{
$configuredParentTheme
=
$this
->
mergeStaticConfig
(
$parentTheme
)
;
$baseThemeConfig
=
array_replace_recursive
(
$baseThemeConfig
,
$configuredParentTheme
)
;
$labels
=
array_replace_recursive
(
$labels
,
$parentTheme
->
getLabels
(
)
??
[
]
)
;
$theme
=
$themes
->
get
(
$themeId
)
;
if
(
!
$theme
)
{
throw
new
InvalidThemeException
(
$themeId
)
;
}
$baseThemeConfig
=
[
]
;
if
(
$withBase
)
{
$baseTheme
=
$themes
->
filter
(
fn
(
ThemeEntity
$themeEntry
)
=>
$themeEntry
->
getTechnicalName
(
)
===
$this
->baseTheme
)
->
first
(
)
;
\
assert
(
$baseTheme
!== null
)
;
$baseThemeConfig
=
$this
->
mergeStaticConfig
(
$baseTheme
)
;
}
if
(
$theme
->
getParentThemeId
(
)
)
{
$parentThemes
=
$this
->
getParentThemeIds
(
$themes
,
$theme
)
;
foreach
(
$parentThemes
as
$parentTheme
)
{
$configuredParentTheme
=
$this
->
mergeStaticConfig
(
$parentTheme
)
;
$baseThemeConfig
=
array_replace_recursive
(
$baseThemeConfig
,
$configuredParentTheme
)
;
}
}