fix bug issue 163 Address JSON string not valid

This commit is contained in:
nobohan 2021-06-22 12:26:56 +02:00
parent 4e6454d7de
commit ac47a75a75

View File

@ -297,18 +297,16 @@ class PersonAddressController extends AbstractController
*/ */
protected function findAddressById(Person $person, $address_id) protected function findAddressById(Person $person, $address_id)
{ {
// filtering address $address = $this->getDoctrine()->getManager()
$criteria = Criteria::create() ->getRepository(Address::class)
->where(Criteria::expr()->eq('id', $address_id)) ->find($address_id)
->setMaxResults(1); ;
$addresses = $person->getAddresses()->matching($criteria);
if (count($addresses) === 0) { if (!$person->getAddresses()->contains($address)) {
throw $this->createNotFoundException("Address with id $address_id " throw $this->createAccessDeniedException("Not allowed to see this address");
. "matching person $person_id not found ");
} }
return $addresses->first(); return $address;
} }
/** /**