Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
reduceElementKeys example
if
(
null ===
$value
)
{
return
;
}
if
(
!\
is_array
(
$value
)
&& !
$value
instanceof \IteratorAggregate
)
{
throw
new
UnexpectedValueException
(
$value
, 'array|IteratorAggregate'
)
;
}
$collectionElements
=
[
]
;
$normalizer
=
$this
->
getNormalizer
(
$constraint
)
;
foreach
(
$value
as
$element
)
{
if
(
$fields
&& !
$element
=
$this
->
reduceElementKeys
(
$fields
,
$element
)
)
{
continue
;
}
$element
=
$normalizer
(
$element
)
;
if
(
\
in_array
(
$element
,
$collectionElements
, true
)
)
{
$this
->context->
buildViolation
(
$constraint
->message
)
->
setParameter
(
'{{ value }}',
$this
->
formatValue
(
$value
)
)
->
setCode
(
Unique::IS_NOT_UNIQUE
)
->
addViolation
(
)
;
if
(
null ===
$value
)
{
return
;
}
if
(
!\
is_array
(
$value
)
&& !
$value
instanceof \IteratorAggregate
)
{
throw
new
UnexpectedValueException
(
$value
, 'array|IteratorAggregate'
)
;
}
$collectionElements
=
[
]
;
$normalizer
=
$this
->
getNormalizer
(
$constraint
)
;
foreach
(
$value
as
$element
)
{
if
(
$fields
&& !
$element
=
$this
->
reduceElementKeys
(
$fields
,
$element
)
)
{
continue
;
}
$element
=
$normalizer
(
$element
)
;
if
(
\
in_array
(
$element
,
$collectionElements
, true
)
)
{
$this
->context->
buildViolation
(
$constraint
->message
)
->
setParameter
(
'{{ value }}',
$this
->
formatValue
(
$value
)
)
->
setCode
(
Unique::IS_NOT_UNIQUE
)
->
addViolation
(
)
;