render('@ChillPerson/AccompanyingCourse/index.html.twig', [ 'accompanyingCourse' => $accompanyingCourse ]); } /** * Show page of Accompanying Course section * * the page show all blocks except one active edit block, managed by vuejs component * that's why title of page is 'edit accompanying course' * * @Route("/{_locale}/parcours/{accompanying_period_id}/show", name="chill_person_accompanying_course_show") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ public function showAction(AccompanyingPeriod $accompanyingCourse): Response { return $this->render('@ChillPerson/AccompanyingCourse/show.html.twig', [ 'accompanyingCourse' => $accompanyingCourse ]); } /** * History page of Accompanying Course section * * the page show anti chronologic history with all actions, title of page is 'accompanying course details' * * @Route("/{_locale}/parcours/{accompanying_period_id}/history", name="chill_person_accompanying_course_history") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ public function historyAction(AccompanyingPeriod $accompanyingCourse): Response { return $this->render('@ChillPerson/AccompanyingCourse/history.html.twig', [ 'accompanyingCourse' => $accompanyingCourse ]); } /** * Sérialise temporairement quelques données pour donner à manger au composant vuejs * @Route( * "/{_locale}/api/parcours/{accompanying_period_id}/show", * name="chill_person_accompanying_course_api_show") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) * @param SerializerInterface $serializer */ public function showAPI(AccompanyingPeriod $accompanyingCourse): Response { $persons = []; foreach ($accompanyingCourse->getParticipations() as $k => $participation ) { /** * @var AccompanyingPeriodParticipation $participation * @var Person $person */ $person = $participation->getPerson(); $persons[$k] = [ 'firstname' => $person->getFirstName(), 'lastname' => $person->getLastName(), 'email' => $person->getEmail(), 'phone' => $person->getPhonenumber(), 'startdate' => ($participation->getStartDate()) ? $participation->getStartDate()->format('Y-m-d') : null, 'enddate' => ($participation->getEndDate()) ? $participation->getEndDate()->format('Y-m-d') : null ]; } $data = [ 'id' => $accompanyingCourse->getId(), 'remark' => $accompanyingCourse->getRemark(), 'closing_motive' => $accompanyingCourse->getClosingMotive() ? $accompanyingCourse->getClosingMotive()->getName()['fr'] : null, 'opening_date' => ($accompanyingCourse->getOpeningDate()) ? $accompanyingCourse->getOpeningDate()->format('Y-m-d') : null, 'closing_date' => ($accompanyingCourse->getClosingDate()) ? $accompanyingCourse->getClosingDate()->format('Y-m-d') : null, 'persons' => $persons ]; /** $normalizer = [new ObjectNormalizer()]; $encoder = [new JsonEncoder()]; $serializer = new Serializer($normalizer, $encoder); $serialized = $serializer->serialize($data,'json', []); * */ $serialized = \json_encode($data); $response = new Response($serialized); $response->headers->set('Content-Type', 'application/json'); return $response; } }