Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
Snippet example
$snippets
=
$this
->
Request
(
)
->
getPost
(
)
;
$isSingleSnippet
= false;
$result
=
[
]
;
if
(
\
array_key_exists
(
'namespace',
$snippets
)
)
{
$snippets
=
[
$snippets
]
;
$isSingleSnippet
= true;
}
foreach
(
$snippets
as
$params
)
{
$snippet
=
new
Snippet
(
)
;
$snippet
->
fromArray
(
$params
)
;
$snippet
->
setDirty
(
true
)
;
if
(
!
$this
->
isSnippetValid
(
$snippet
)
)
{
$result
[
$snippet
->
getId
(
)
]
=
$params
;
continue
;
}
try
{
$this
->
get
(
'models'
)
->
persist
(
$snippet
)
;
$this
->
get
(
'models'
)
->
flush
(
)
;
}