src/Controller/MarriageCertificateController.php line 68

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\MarriageCertificate;
  4. use App\Form\MarriageCertificateType;
  5. use App\Repository\MarriageCertificateRepository;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use App\Form\MarriageCertificateType_1;
  11. use App\Form\TestType;
  12. use App\Form\MarriageCertificate1Type;
  13. /**
  14. * @Route("")
  15. */
  16. /**
  17. * @Route("{_locale?fr}/marriage/certificate",locale="fr",methods={"GET"}, requirements={
  18. * "_locale": "en|fr",
  19. * "_format": "html|xml",
  20. * })")
  21. */
  22. class MarriageCertificateController extends AbstractController
  23. {
  24. /**
  25. * @Route("/", name="marriage_certificate_index", methods={"GET"})
  26. */
  27. public function index(MarriageCertificateRepository $marriageCertificateRepository): Response
  28. {
  29. return $this->render('marriage_certificate/index.html.twig', [
  30. 'marriage_certificates' => $marriageCertificateRepository->findAll(),
  31. ]);
  32. }
  33. /**
  34. * @Route("/complete_marriage", name="marriage_test", methods={"GET","POST"})
  35. */
  36. public function test(Request $request){
  37. $form = $this->createForm(TestType::class);
  38. $form->handleRequest($request);
  39. if ($form->isSubmitted() && $form->isValid()) {
  40. $id = $form['id']->getData();
  41. $val = intval($id);
  42. return $this->redirectToRoute('marriage_certificate_edit', [
  43. 'id' => $val
  44. ]);
  45. }
  46. return $this->render('test/new.html.twig',[
  47. 'form'=>$form->createView()
  48. ]
  49. );
  50. }
  51. /**
  52. * @Route("/new", name="marriage_certificate_new", methods={"GET","POST"})
  53. */
  54. public function new(Request $request): Response
  55. {
  56. $marriageCertificate = new MarriageCertificate();
  57. $form = $this->createForm(MarriageCertificateType::class, $marriageCertificate);
  58. $form->handleRequest($request);
  59. if ($form->isSubmitted() && $form->isValid()) {
  60. $entityManager = $this->getDoctrine()->getManager();
  61. $entityManager->persist($marriageCertificate);
  62. $entityManager->flush();
  63. return $this->redirectToRoute('marriage_certificate_index');
  64. }
  65. return $this->render('marriage_certificate/new.html.twig', [
  66. 'marriage_certificate' => $marriageCertificate,
  67. 'form' => $form->createView(),
  68. ]);
  69. }
  70. /**
  71. * @Route("/{id}", name="marriage_certificate_show", methods={"GET"})
  72. */
  73. public function show(MarriageCertificate $marriageCertificate): Response
  74. {
  75. return $this->render('marriage_certificate/show.html.twig', [
  76. 'marriage_certificate' => $marriageCertificate,
  77. ]);
  78. }
  79. /**
  80. * @Route("/{id}/edit", name="marriage_certificate_edit", methods={"GET","POST"})
  81. */
  82. public function edit(Request $request, MarriageCertificate $marriageCertificate): Response
  83. {
  84. $form = $this->createForm(MarriageCertificateType::class, $marriageCertificate);
  85. $form->handleRequest($request);
  86. if ($form->isSubmitted() && $form->isValid()) {
  87. $this->getDoctrine()->getManager()->flush();
  88. return $this->redirectToRoute('marriage_certificate_index');
  89. }
  90. return $this->render('marriage_certificate/edit.html.twig', [
  91. 'marriage_certificate' => $marriageCertificate,
  92. 'form' => $form->createView(),
  93. ]);
  94. }
  95. /**
  96. * @Route("/{id}", name="marriage_certificate_delete", methods={"DELETE"})
  97. */
  98. public function delete(Request $request, MarriageCertificate $marriageCertificate): Response
  99. {
  100. if ($this->isCsrfTokenValid('delete'.$marriageCertificate->getId(), $request->request->get('_token'))) {
  101. $entityManager = $this->getDoctrine()->getManager();
  102. $entityManager->remove($marriageCertificate);
  103. $entityManager->flush();
  104. }
  105. return $this->redirectToRoute('marriage_certificate_index');
  106. }
  107. }