get('request_stack')->getCurrentRequest()->getLocale(); $translator = $container->get('translator'); $reason = $container->get('net15.form.forge.reasons.manager')->getByPublicKey($publicKey); if ($this->isCsrfTokenValid('form_forge_new_mapping_event', $request->request->get('_csrf_token'))){ $newEvent = $container->get('net15.form.forge.mapping.events.manager')->createEventName($request->get('event-name'), $reason); // Message confirmation or error if($newEvent !== null) $container->get('session')->getFlashBag()->set('success', $translator->trans('form_forge.mapping_event.message.create.success', array(), 'messages', $locale)); else $container->get('session')->getFlashBag()->set('errors', $translator->trans('form_forge.mapping_event.message.create.errors', array(), 'messages', $locale)); } $events = $container->get('net15.form.forge.mapping.events.manager')->getAll(); return $this->render('@FormForge/FormForgeMappingEvent/mapping.event.html.twig', [ 'events' => $events, 'reason' => $reason ]); } public function removeMappingEvent(int $id, string $publicKey, Request $request, ContainerInterface $container){ $removeEvent = $container->get('net15.form.forge.mapping.events.manager')->deleteEventName($id); $locale = $container->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $container->get('translator'); if($removeEvent !== null) $container->get('session')->getFlashBag()->set('success', $translator->trans('form_forge.mapping_event.message.delete.success', array(), 'messages', $locale)); else $container->get('session')->getFlashBag()->set('errors', $translator->trans('form_forge.mapping_event.message.delete.errors', array(), 'messages', $locale)); return $this->redirectToRoute('form_forge_new_mapping_event',['publicKey'=>$publicKey]); } public function addMappingEvent(string $publicKey, Request $request, ContainerInterface $container){ $reason = $container->get('net15.form.forge.reasons.manager')->getByPublicKey($publicKey); $locale = $container->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $container->get('translator'); if ($this->isCsrfTokenValid('form_forge_choice_mapping_event', $request->request->get('_csrf_token'))){ $newEvent = $container->get('net15.form.forge.mapping.events.manager')->addEventToReason($reason, $request->request->all()); if($newEvent !== null) $container->get('session')->getFlashBag()->set('success', $translator->trans('form_forge.mapping_event.message.update.success', array(), 'messages', $locale)); else $container->get('session')->getFlashBag()->set('errors', $translator->trans('form_forge.mapping_event.message.update.errors', array(), 'messages', $locale)); } return $this->redirectToRoute('form_forge_new_mapping_event',['publicKey'=>$publicKey]); } }