diff --git a/src/Service/ObjectService.php b/src/Service/ObjectService.php index b45996c0..36b97e56 100755 --- a/src/Service/ObjectService.php +++ b/src/Service/ObjectService.php @@ -270,13 +270,15 @@ public function getCompleteEntity($id, $anrContext = MonarcObject::CONTEXT_BDC, // Retrieve parent recursively if ($anrContext == MonarcObject::CONTEXT_ANR) { //Check if the object is linked to the $anr - $found = false; - $anrObject = null; - foreach ($object->getAnrs() as $a) { - if ($a->getId() === $anr) { - $found = true; - $anrObject = $a; - break; + $found = $object->getAnr() !== null; + $anrObject = $object->getAnr(); + if ($anrObject === null) { + foreach ($object->getAnrs() as $a) { + if ($a->getId() === $anr) { + $found = true; + $anrObject = $a; + break; + } } }