src/Controller/FeedbackController.php line 22

  1. <?php
  2. namespace App\Controller;
  3. use App\Dto\FeedbackDto;
  4. use App\Exception\AppException;
  5. use App\Form\FeedbackType;
  6. use App\Notification\NotifierInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. #[Route('/feedback')]
  12. class FeedbackController extends AbstractController
  13. {
  14.     /**
  15.      * @throws AppException
  16.      */
  17.     #[Route('/'name'app_feedback'methods: ['GET''POST'])]
  18.     public function feedback(
  19.         Request           $request,
  20.         NotifierInterface $notifier,
  21.     ): Response
  22.     {
  23.         $feedback = new FeedbackDto();
  24.         $form $this->createForm(FeedbackType::class, $feedback);
  25.         $form->handleRequest($request);
  26.         if ($form->isSubmitted() && $form->isValid()) {
  27.             $notifier->sendFeedback($feedback);
  28.         }
  29.         return $this->render('feedback/feedback.html.twig', [
  30.             'form' => $form,
  31.         ]);
  32.     }
  33. }