Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setPresetData example
throw
new
NoResultException
(
)
;
}
$presetData
=
json_decode
(
$preset
->
getPresetData
(
)
, true
)
;
if
(
empty
(
$presetData
[
'elements'
]
)
)
{
return
$preset
->
getPresetData
(
)
;
}
$presetData
[
'elements'
]
=
$this
->
refreshElementData
(
$presetData
[
'elements'
]
)
;
$preset
->
setPresetData
(
json_encode
(
$presetData
)
)
;
if
(
!
$preset
->
getAssetsImported
(
)
)
{
$preset
->
setAssetsImported
(
true
)
;
}
$this
->modelManager->
flush
(
$preset
)
;
return
$this
->
preparePresetData
(
$presetData
)
;
}
private
function
refreshElementData
(
array
$elements
)
: array
{
$syncData
=
new
ParameterBag
(
$presetData
[
'syncData'
]
)
;
$this
->
setAssetPaths
(
$syncData
)
;
try
{
$element
=
$handler
->
import
(
$element
,
$syncData
)
;
}
catch
(
Exception
$e
)
{
throw
new
PresetAssetImportException
(
$e
->
getMessage
(
)
)
;
}
$presetData
[
'syncData'
]
=
$syncData
->
all
(
)
;
$preset
->
setPresetData
(
json_encode
(
$presetData
)
)
;
$this
->
synchronizeData
(
$preset
,
$element
)
;
}
/** * {@inheritdoc} */
public
function
prepareAssetExport
(
Preset
$preset
)
{
$presetData
=
json_decode
(
$preset
->
getPresetData
(
)
, true
)
;