src/Controller/SecurityController.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Mailer\MailerInterface;
  5. use Symfony\Component\Mime\Email;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/email", name="email_app")
  13.      */
  14.     public function email(MailerInterface $mailer) {
  15.         $email = (new Email())
  16.             ->from('reply@numso.com.br')
  17.             ->to('brunofredericot@gmail.com')
  18.             ->subject('Time for Symfony Mailer!')
  19.             ->text('Sending emails is fun again!')
  20.             ->html('<p>See Twig integration for better HTML integration!</p>');
  21.         $mailer->send($email);
  22.     }
  23.     /**
  24.      * @Route("/login", name="app_login")
  25.      */
  26.     public function index(AuthenticationUtils $authenticationUtils): Response {
  27.         // get the login error if there is one
  28.         $error $authenticationUtils->getLastAuthenticationError();
  29.         // last username entered by the user
  30.         $lastUsername $authenticationUtils->getLastUsername();
  31.         return $this->render('login/index.html.twig', [
  32.             'controller_name' => 'LoginController',
  33.             'last_username' => $lastUsername,
  34.             'error' => $error
  35.         ]);
  36.     }
  37.     /**
  38.      * @Route("/logout", name="app_logout")
  39.      */
  40.     public function logout()
  41.     {
  42.         throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  43.     }
  44. }