src/Controller/VolunteersController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Volunteers;
  4. use App\Form\VolunteersType;
  5. use App\Repository\SectionTitleRepository;
  6. use App\Service\FileUploader;
  7. use App\Notification\VolunteersNotification;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. // use App\Notification\ConsultationNotification;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use MercurySeries\FlashyBundle\FlashyNotifier;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. class VolunteersController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("/bilimon-inscription", name="app_volunteers_index")
  19.      */
  20.     public function index(FlashyNotifier $flashyVolunteersNotification $notificationRequest $requestFileUploader $fileUploaderEntityManagerInterface $entityManagerSectionTitleRepository $titleRepository)
  21.     {
  22.         $title $titleRepository->findTitleByTag('registrationPage');
  23.         $volunteers = new Volunteers;
  24.         $form $this->createForm(VolunteersType::class, $volunteers);
  25.         $form->handleRequest($request);
  26.         if ($form->isSubmitted() && $form->isValid()) {
  27.             // /** @var UploadedFile $brochureFile */
  28.             $brochureFile $form->get('passport')->getData();
  29.             if ($brochureFile) {
  30.                 $brochureFileName $fileUploader->upload($brochureFile);
  31.                 $volunteers->setBrochureFilename($brochureFileName);
  32.             }
  33.             $notification->notify($volunteers);
  34.             $flashy->success('Votre candidature a bien été envoyée. Nous vous contacterons sous peu');
  35.             return $this->redirectToRoute('app_thanks_index');
  36.         }
  37.         // // tell Doctrine you want to (eventually) save the Product (no queries yet)
  38.         // $entityManager->persist($volunteers);
  39.         // // actually executes the queries (i.e. the INSERT query)
  40.         // $entityManager->flush();
  41.         return $this->render('registration/index.html.twig', [
  42.             'form' => $form->createView(),
  43.             'titles' => $title
  44.         ]);
  45.     }
  46. }