Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ParentFieldNotFoundException example
private
function
getParentField
(
EntityDefinition
$definition
)
: ?FkField
{
if
(
!
$definition
->
isInheritanceAware
(
)
)
{
return
null;
}
/** @var ManyToOneAssociationField|null $parent */
$parent
=
$definition
->
getFields
(
)
->
get
(
'parent'
)
;
if
(
!
$parent
)
{
throw
new
ParentFieldNotFoundException
(
$definition
)
;
}
if
(
!
$parent
instanceof ManyToOneAssociationField
)
{
throw
new
InvalidParentAssociationException
(
$definition
,
$parent
)
;
}
$fk
=
$definition
->
getFields
(
)
->
getByStorageName
(
$parent
->
getStorageName
(
)
)
;
if
(
!
$fk
)
{
throw
new
CanNotFindParentStorageFieldException
(
$definition
)
;
}
private
function
getParentField
(
EntityDefinition
$definition
)
: ?FkField
{
if
(
!
$definition
->
isInheritanceAware
(
)
)
{
return
null;
}
/** @var ManyToOneAssociationField|null $parent */
$parent
=
$definition
->
getFields
(
)
->
get
(
'parent'
)
;
if
(
!
$parent
)
{
throw
new
ParentFieldNotFoundException
(
$definition
)
;
}
if
(
!
$parent
instanceof ManyToOneAssociationField
)
{
throw
new
InvalidParentAssociationException
(
$definition
,
$parent
)
;
}
$fk
=
$definition
->
getFields
(
)
->
getByStorageName
(
$parent
->
getStorageName
(
)
)
;
if
(
!
$fk
)
{
throw
new
CanNotFindParentStorageFieldException
(
$definition
)
;
}