src/Controller/SecurityController.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. class SecurityController extends AbstractController
  8. {
  9.     #[Route('/'name'app_login')]
  10.     public function login(AuthenticationUtils $authenticationUtils): Response
  11.     {
  12.         // get the login error if there is one
  13.         $error $authenticationUtils->getLastAuthenticationError();
  14.         // last username entered by the user
  15.         $lastUsername $authenticationUtils->getLastUsername();
  16.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  17.     }
  18.     #[Route('/logout'name'app_logout')]
  19.     public function logout()
  20.     {
  21.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  22.     }
  23.     #[Route('/gen'name'generate')]
  24.     public function generate()
  25.     {
  26.         $entity_name 'Sponsorship Type';
  27.         $entity_small preg_replace('/\s+/''_'strtolower($entity_name));
  28.         echo "INSERT INTO `permission`(`name`, `code`, `description`) VALUES ('" $entity_name " Create','" $entity_small "_create', 'Allows users to create " $entity_name "');";
  29.         echo "INSERT INTO `permission`(`name`, `code`, `description`) VALUES ('" $entity_name " Edit','" $entity_small "_edit', 'Allows users to edit " $entity_name "');";
  30.         echo "INSERT INTO `permission`(`name`, `code`, `description`) VALUES ('" $entity_name " Delete','" $entity_small "_delete', 'Allows users to delete " $entity_name "');";
  31.         echo "INSERT INTO `permission`(`name`, `code`, `description`) VALUES ('" $entity_name " Show','" $entity_small "_show', 'Allows users to view " $entity_name "');";
  32.         echo "INSERT INTO `permission`(`name`, `code`, `description`) VALUES ('" $entity_name " List','" $entity_small "_index', 'Allows users to list " $entity_name "');";
  33.         // return $entity_spaceless;
  34.     }
  35. }