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)
{
// filtering address
$criteria = Criteria::create()
->where(Criteria::expr()->eq('id', $address_id))
->setMaxResults(1);
$addresses = $person->getAddresses()->matching($criteria);
$address = $this->getDoctrine()->getManager()
->getRepository(Address::class)
->find($address_id)
;
if (count($addresses) === 0) {
throw $this->createNotFoundException("Address with id $address_id "
. "matching person $person_id not found ");
if (!$person->getAddresses()->contains($address)) {
throw $this->createAccessDeniedException("Not allowed to see this address");
}
return $addresses->first();
return $address;
}
/**