diff --git a/src/Service/AssentService.php b/src/Service/AssentService.php index 05120b6..37ac75e 100644 --- a/src/Service/AssentService.php +++ b/src/Service/AssentService.php @@ -150,24 +150,24 @@ public function updateAssentHandler(array $data, array $config) throw new NotFoundHttpException("The assent with id {$data['path']['id']} was not found."); } - $assentData = $assent->toArray(); + if ($assent->getValue('status') === 'granted') { + // get brp person from the logged in user + $brpPersons = $this->cacheService->searchObjects(null, ['burgerservicenummer' => $this->security->getUser()->getPerson()], [$brpSchema->getId()->toString()])['results']; + $brpPerson = null; + if (count($brpPersons) === 1) { + $brpPerson = $this->entityManager->find('App:ObjectEntity', $brpPersons[0]['_self']['id']); + }//end if - // get brp person from the logged in user - $brpPersons = $this->cacheService->searchObjects(null, ['burgerservicenummer' => $this->security->getUser()->getPerson()], [$brpSchema->getId()->toString()])['results']; - $brpPerson = null; - if (count($brpPersons) === 1) { - $brpPerson = $this->entityManager->find('App:ObjectEntity', $brpPersons[0]['_self']['id']); - }//end if + $person = $assent->getValue('contact'); - $person = $assent->getValue('contact'); + if ($person === false) { + $person = null; + } - if ($person === false) { - $person = null; - } + $person = $this->createPerson([], $brpPerson, $person); - $person = $this->createPerson([], $brpPerson, $person); - - $assent->hydrate(['contact' => $person]); + $assent->hydrate(['contact' => $person]); + } $this->entityManager->persist($assent); $this->entityManager->flush();