- RelationBuilder now returns NULL if no entity were found AND given field is nullable
This commit is contained in:
parent
3c2ae86653
commit
573d4cc06b
|
@ -109,7 +109,13 @@ class RelationBuilder
|
|||
|
||||
$this->entity->eventExecute(Event\EntityRelationLoadInterface::class, $name, $this->repository);
|
||||
|
||||
return call_user_func([ $this->repository, $relation->function() ]) ?? $this->instanciateEmptyEntity($name, $relation);
|
||||
$value = call_user_func([ $this->repository, $relation->function() ]) ?? null;
|
||||
|
||||
if ($value === null && $this->resolver->reflectedClass->getProperties(true)[$name]->allowsNull()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value ?? $this->instanciateEmptyEntity($name, $relation);
|
||||
|
||||
case $relation->isOneToMany():
|
||||
$this->oneToMany($name, $relation);
|
||||
|
|
Loading…
Reference in New Issue