Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getOnDelete example
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_'
)
)
{
return
;
}
if
(
$field
->
getOnDelete
(
)
=== AssociationField::CASCADE
)
{
throw
new
\
RuntimeException
(
\
sprintf
(
'Cascade delete and referencing core tables are not allowed, field %s',
$field
->
getName
(
)
)
)
;
}
if
(
$field
->
isReverseRequired
(
)
)
{
throw
new
\
RuntimeException
(
\
sprintf
(
'Reverse required when referencing core tables is not allowed, field %s',
$field
->
getName
(
)
)
)
;
}
}
}