Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getRequiredPlugins example
$zipPath
= 'images/' .
basename
(
$path
)
;
$zip
->
addFromString
(
$zipPath
,
$fileContent
)
;
$path
=
$zipPath
;
}
unset
(
$path
)
;
$syncData
->
set
(
'assets',
$assets
)
;
$presetData
[
'syncData'
]
=
$syncData
->
all
(
)
;
$exportData
=
[
'requiredPlugins' =>
json_decode
(
$preset
->
getRequiredPlugins
(
)
, true
)
,
'emotionTranslations' =>
$preset
->
getEmotionTranslations
(
)
,
'presetData' =>
json_encode
(
$presetData
)
,
]
;
$zip
->
addFromString
(
'emotion.json',
json_encode
(
$exportData
, JSON_THROW_ON_ERROR
)
)
;
if
(
!
$zip
->
close
(
)
)
{
throw
new
Exception
(
sprintf
(
'Could not close zip file "%s"!',
$filename
)
)
;
}
$this
->presetResource->
delete
(
$preset
->
getId
(
)
)
;
$emotionData
[
'modified'
]
,
$emotionData
[
'previewId'
]
,
$emotionData
[
'previewSecret'
]
)
;
if
(
!
$keepName
)
{
unset
(
$emotionData
[
'name'
]
)
;
}
$emotionData
[
'active'
]
= false;
$requiredPlugins
=
$this
->
getRequiredPlugins
(
$emotionData
[
'elements'
]
)
;
$emotionTranslations
=
$this
->
getTranslations
(
$emotionData
[
'elements'
]
,
$emotionData
[
'id'
]
)
;
unset
(
$emotionData
[
'id'
]
)
;
$emotionData
[
'elements'
]
=
$this
->
cleanupElements
(
$emotionData
[
'elements'
]
)
;
$data
[
'emotionTranslations'
]
=
json_encode
(
$emotionTranslations
)
;
$data
[
'requiredPlugins'
]
=
$requiredPlugins
;
$data
[
'presetData'
]
=
json_encode
(
$emotionData
)
;
return
$data
;
}
/** @var PresetMetaDataInterface $metaData */
foreach
(
$presetMetaData
as
$metaData
)
{
$presetData
=
[
'name' =>
$metaData
->
getName
(
)
,
'premium' =>
$metaData
->
getPremium
(
)
,
'custom' =>
$metaData
->
getCustom
(
)
,
'thumbnail' =>
$metaData
->
getThumbnail
(
)
,
'preview' =>
$metaData
->
getPreview
(
)
,
'translations' =>
$metaData
->
getTranslations
(
)
,
'presetData' =>
json_encode
(
$metaData
->
getPresetData
(
)
)
,
'requiredPlugins' =>
$metaData
->
getRequiredPlugins
(
)
,
'assetsImported' =>
$metaData
->
getAssetsImported
(
)
,
]
;
$slugifiedName
=
$this
->slugService->
slugify
(
$metaData
->
getName
(
)
)
;
$preset
=
$modelManager
->
getRepository
(
Preset::
class
)
->
findOneBy
(
[
'name' =>
$slugifiedName
]
)
;
if
(
!
$preset
)
{
$this
->presetResource->
create
(
$presetData
)
;
continue
;
}