|
@@ -0,0 +1,52 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Controller;
|
|
|
+
|
|
|
+use App\Form\PageType;
|
|
|
+use App\Repository\PageRepository;
|
|
|
+use Doctrine\ORM\EntityManagerInterface;
|
|
|
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
+use Symfony\Component\HttpFoundation\Request;
|
|
|
+use Symfony\Component\HttpFoundation\Response;
|
|
|
+use Symfony\Component\Routing\Attribute\Route;
|
|
|
+use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
+
|
|
|
+class PageController extends AbstractController
|
|
|
+{
|
|
|
+ #[Route('/contact', name: 'app_page_contact')]
|
|
|
+ public function index(
|
|
|
+ PageRepository $pageRepository
|
|
|
+ ): Response
|
|
|
+ {
|
|
|
+ $page = $pageRepository->find('1');
|
|
|
+
|
|
|
+ return $this->render('page/index.html.twig', [
|
|
|
+ 'page' => $page
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ #[Route('/page/contact/edit', name: 'app_page_contact_edit')]
|
|
|
+ #[IsGranted('ROLE_CONTACT')]
|
|
|
+ public function contactEdit(
|
|
|
+ Request $request,
|
|
|
+ PageRepository $pageRepository,
|
|
|
+ EntityManagerInterface $entityManager
|
|
|
+ ): Response
|
|
|
+ {
|
|
|
+ $page = $pageRepository->find('1');
|
|
|
+ $form = $this->createForm(PageType::class, $page);
|
|
|
+
|
|
|
+ $form->handleRequest($request);
|
|
|
+
|
|
|
+ if ($form->isSubmitted() && $form->isValid()) {
|
|
|
+ $entityManager->flush();
|
|
|
+
|
|
|
+ return $this->redirectToRoute('app_page_contact', [], Response::HTTP_SEE_OTHER);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->render('page/edit.html.twig', [
|
|
|
+ 'page' => $page,
|
|
|
+ 'form' => $form,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+}
|