src/Controller/CustomerSecurityController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Customer\Customer;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  10. class CustomerSecurityController extends AbstractController
  11. {
  12.     private $doctrine;
  13.     public function __construct(ManagerRegistry $doctrine)
  14.     {
  15.         $this->doctrine $doctrine;
  16.     }
  17.     /**
  18.      * @Route("/connexion", name="customer_login")
  19.      */
  20.     public function login(AuthenticationUtils $authenticationUtilsRequest $request): Response
  21.     {
  22.         $targePath "";
  23.         if($request->query->get('back')){
  24.             $targePath $request->query->get('back');
  25.             $settings $request->query->all();
  26.             $link '?';
  27.             foreach ($settings as $setting => $value) {
  28.                 if($setting != 'back'){
  29.                     $targePath .= $link.$setting.'='.$value;
  30.                     $link '&';
  31.                 }
  32.             }
  33.         }
  34.         // dd($this);
  35.         // $customerEntityManager = $this->doctrine->getManager('customer');
  36.         if ($this->getUser()) {
  37.             return $this->redirectToRoute('account');
  38.         }
  39.         // get the login error if there is one
  40.         $error $authenticationUtils->getLastAuthenticationError();
  41.         // last username entered by the user
  42.         $lastUsername $authenticationUtils->getLastUsername();
  43.         return $this->render('mon-compte/login.html.twig', ['last_username' => $lastUsername'error' => $error'targetPath' => $targePath]);
  44.     }
  45.     /**
  46.      * @Route("/deconnexion", name="customer_logout")
  47.      */
  48.     public function logout(): void
  49.     {
  50.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  51.     }
  52. }