src/Controller/RegistrationController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Society;
  4. use App\Service\ExportAndImportTable;
  5. use App\Form\RegistrationFormType;
  6. use App\Security\SocietyAuthenticator;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;
  14. class RegistrationController extends AbstractController
  15. {
  16.     /**
  17.      * @Route("/register", name="register")
  18.      */
  19.     public function register(Request $requestUserPasswordHasherInterface $userPasswordHasherUserAuthenticatorInterface $authenticatorEntityManagerInterface $entityManagerSocietyAuthenticator $formAuthenticator): Response
  20.     {
  21.         $society = new Society();
  22.         $form $this->createForm(RegistrationFormType::class, $society);
  23.         $form->handleRequest($request);
  24.         if ($form->isSubmitted() && $form->isValid()) {
  25.             // encode the plain password
  26.             $society->setPassword(
  27.                 $userPasswordHasher->hashPassword(
  28.                     $society,
  29.                     $form->get('plainPassword')->getData()
  30.                 )
  31.             );
  32.             $entityManager->persist($society);
  33.             $entityManager->flush();
  34.             // do anything else you need here, like send an email
  35.             // substitute the previous line (redirect response) with this one.
  36.             return $authenticator->authenticateUser(
  37.                 $society,
  38.                 $formAuthenticator,
  39.                 $request
  40.             );
  41.              return $this->redirectToRoute('home');
  42.         }
  43.         return $this->render('registration/register.html.twig', [
  44.             'registrationForm' => $form->createView()
  45.         ]);
  46.     }
  47.         /**
  48.      * @Route("/home/portail-administration/Gestion-des-Bases-de-donnees/table/export/{table_name}", name="app_portail_administration-bdd_table-export")
  49.      */
  50.      
  51.      public function tableExportFile($table_name,Request $requestExportAndImportTable $ExportAndImportTable): Response
  52.      {
  53.         
  54.          return $ExportAndImportTable->ExportTable($table_name); 
  55.  
  56.      }
  57.    
  58. }