Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
isSnippetValid example
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
(
)
;
}
catch
(
Exception
$e
)
{
$this
->
View
(
)
->
assign
(
[
'success' => false, 'message' =>
$e
->
getMessage
(
)
]
)
;
return
;
}