Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getHelpTexts example
$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
(
)
??
[
]
)
;
$helpTexts
=
array_replace_recursive
(
$helpTexts
,
$parentTheme
->
getHelpTexts
(
)
??
[
]
)
;
}
}
$configuredTheme
=
$this
->
mergeStaticConfig
(
$theme
)
;
$theme
=
$this
->
getTheme
(
$bundle
)
;
static
::
assertInstanceOf
(
ThemeTranslationCollection::
class
,
$theme
->
getTranslations
(
)
)
;
static
::
assertCount
(
1,
$theme
->
getTranslations
(
)
)
;
static
::
assertEquals
(
'en-GB',
$theme
->
getTranslations
(
)
->
first
(
)
?->
getLanguage
(
)
?->
getLocale
(
)
?->
getCode
(
)
)
;
static
::
assertEquals
(
[
'fields.sw-image' => 'test label',
]
,
$theme
->
getTranslations
(
)
->
first
(
)
?->
getLabels
(
)
)
;
static
::
assertEquals
(
[
'fields.sw-image' => 'test help',
]
,
$theme
->
getTranslations
(
)
->
first
(
)
?->
getHelpTexts
(
)
)
;
}
public
function
testItUsesEnglishTranslationsAsFallbackIfDefaultLanguageIsNotProvided
(
)
: void
{
$bundle
=
$this
->
getThemeConfigWithLabels
(
)
;
$this
->
changeDefaultLanguageLocale
(
'xx-XX'
)
;
$this
->themeLifecycleService->
refreshTheme
(
$bundle
,
$this
->context
)
;
$theme
=
$this
->
getTheme
(
$bundle
)
;