Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
createFromThemeJson example
/** @var array<string, mixed> $data */
$data
=
json_decode
(
$fileContent
, true
)
;
if
(
json_last_error
(
)
!== \JSON_ERROR_NONE
)
{
throw
new
ThemeCompileException
(
$name
,
'Unable to parse theme.json. Message: ' .
json_last_error_msg
(
)
)
;
}
$config
=
$this
->
createFromThemeJson
(
$name
,
$data
,
$path
)
;
}
catch
(
ThemeCompileException
$e
)
{
throw
$e
;
}
catch
(
\Exception
$e
)
{
throw
new
ThemeCompileException
(
$name
,
sprintf
(
'Got exception while parsing theme config. Exception message "%s"',
$e
->
getMessage
(
)
)
,
$e
)
;
}
private
function
updateMediaInConfiguration
(
?ThemeEntity
$theme
,
StorefrontPluginConfiguration
$pluginConfiguration
,
Context
$context
)
: array
{
$media
=
[
]
;
$themeData
=
[
]
;
$themeFolderId
=
$this
->
getMediaDefaultFolderId
(
$context
)
;
$installedConfiguration
= null;
if
(
$theme
&& \
is_array
(
$theme
->
getThemeJson
(
)
)
&&
$this
->pluginConfigurationFactory
)
{
$installedConfiguration
=
$this
->pluginConfigurationFactory->
createFromThemeJson
(
$theme
->
getTechnicalName
(
)
?? 'childTheme',
$theme
->
getThemeJson
(
)
,
$pluginConfiguration
->
getBasePath
(
)
,
false
)
;
}
if
(
$pluginConfiguration
->
getPreviewMedia
(
)
&&
$pluginConfiguration
->
getPreviewMedia
(
)
!==
$installedConfiguration
?->
getPreviewMedia
(
)
&&
(