em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class) ->findOneByEntity(Person::class); if ($cFDefaultGroup) { $cFGroup = $cFDefaultGroup->getCustomFieldsGroup(); } return $cFGroup; } /** * @ParamConverter("person", options={"id": "person_id"}) */ #[Route(path: '/{_locale}/person/household/{person_id}/history', name: 'chill_person_household_person_history', methods: ['GET', 'POST'])] public function householdHistoryByPerson(Request $request, Person $person): Response { $this->denyAccessUnlessGranted( 'CHILL_PERSON_SEE', $person, 'You are not allowed to see this person.' ); $event = new PrivacyEvent($person); $this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT); return $this->render( '@ChillPerson/Person/household_history.html.twig', [ 'person' => $person, ] ); } #[Route(path: '/{_locale}/person/{person_id}/general', name: 'chill_person_view')] public function viewAction(int $person_id) { $person = $this->_getPerson($person_id); if (null === $person) { throw $this->createNotFoundException("Person with id {$person_id} not".' found on this server'); } $this->denyAccessUnlessGranted( 'CHILL_PERSON_SEE', $person, 'You are not allowed to see this person.' ); $event = new PrivacyEvent($person); $this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT); return $this->render( '@ChillPerson/Person/view.html.twig', [ 'person' => $person, 'cFGroup' => $this->getCFGroup(), 'alt_names' => $this->configPersonAltNameHelper->getChoices(), ] ); } /** * easy getting a person by his id. * * @return Person */ private function _getPerson(int $id) { return $this->personRepository->find($id); } /** * @return \Symfony\Component\Validator\ConstraintViolationListInterface */ private function _validatePersonAndAccompanyingPeriod(Person $person) { $errors = $this->validator ->validate($person, null, ['creation']); // validate accompanying periods $periods = $person->getAccompanyingPeriods(); foreach ($periods as $period) { $period_errors = $this->validator ->validate($period); // group errors : foreach ($period_errors as $error) { $errors->add($error); } } return $errors; } }