get('net15.form.forge.reasons.manager')->getByPublicKey($publicKey); $locale = $request->getLocale(); return $this->render('@FormForge/FormForgeGenerate/generate.form.html.twig',[ 'reason' => $reason, 'csrf_key' => $reason->getId(), 'customFieldTicket' =>$reason->getFormForgeFields()->getValues(), 'lang' => $locale ]); } /** * @param string $tag * @param Request $request * @param ContainerInterface $container * @return Response */ public function rendererAction(string $tag, Request $request, ContainerInterface $container) { $reason = $container->get('net15.form.forge.reasons.manager')->getByTag($tag); $locale = $request->getLocale(); return $this->render('@FormForge/FormForgeGenerate/generate.twig.form.html.twig',[ 'reason' => $reason, 'csrf_key' => $reason->getId(), 'customFieldTicket' =>$reason->getFormForgeFields()->getValues(), 'lang' => $locale ]); } /* * load FormForge for testing by slug element */ public function formLoaderTest(string $lang, string $slugForm, ContainerInterface $container, Request $request) { $form_forge_reason_testing = $container->get('net15.slug_manager')->getMappedElement($lang, $slugForm, FormForgeReason::class); return $this->render('@FormForge/FormForgeGenerate/generate.form.html.twig',[ 'reason' => $form_forge_reason_testing, 'csrf_key' => $form_forge_reason_testing->getId(), 'customFieldTicket' =>$form_forge_reason_testing->getFormForgeFields()->getValues(), 'lang' => $lang ]); } /* * generate FormForge for front by slug element */ public function formGeneratorLoader(string $lang, string $slugForm, ContainerInterface $container, Request $request) { $form_forge_reason = $container->get('net15.slug_manager')->getMappedElement($lang, $slugForm, FormForgeReason::class); return $this->render('@FormForge/FormForgeGenerate/generate.twig.form.html.twig',[ 'reason' => $form_forge_reason, 'csrf_key' => $form_forge_reason->getId(), 'customFieldTicket' =>$form_forge_reason->getFormForgeFields()->getValues(), 'lang' => $lang ]); } /** * @param Request $request * @param ContainerInterface $container * @return Response * @throws \Exception */ public function createCustomFieldResponseAction(Request $request, ContainerInterface $container) { $user = null; if ($this->getUser()){ $user = $this->getUser(); } $reason = $container->get('net15.form.forge.reasons.manager')->getByPublicKey($request->get('reasonPK')); $csrf = $request->get('csrf_form'); if($this->isCsrfTokenValid($reason->getId(),$csrf)) { $fieldResponse = $container->get('net15.form.forge.fields.response.manager')->createFieldResponse( $csrf, $reason, $reason->getFormForgeFields(), $request->get('responses'), $request->getLocale(), $user ); } if ($reason->getRedirectURL() != ''){ $url = $this->generateUrl($reason->getRedirectURL()); }else{ $url = $this->generateUrl('homepage'); } return new Response($url); } }