Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
validateAssociation example
if
(
!
$entity
->
hasField
(
$label
)
)
{
throw
CustomEntityException::
labelPropertyNotDefined
(
$label
)
;
}
if
(
!
$entity
->
getField
(
$label
)
instanceof StringField
)
{
throw
CustomEntityException::
labelPropertyWrongType
(
$label
)
;
}
}
foreach
(
$entity
->
getFields
(
)
as
$field
)
{
if
(
$field
instanceof OneToManyField
)
{
$this
->
validateAssociation
(
$field
)
;
}
}
}
}
private
function
validateAssociation
(
OneToManyField
$field
)
: void
{
$reference
=
$field
->
getReference
(
)
;
// reference on custom entity table
if
(
\
str_starts_with
(
$reference
, 'custom_entity_'
)
|| \
str_starts_with
(
$reference
, 'ce_'
)
)
{