src/Controller/SecurityController.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Menu;
  4. use App\Entity\User;
  5. use App\Repository\MenuRepository;
  6. use App\Repository\PaginaRepository;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. class SecurityController extends BaseController {
  12.     public $menuRepository;
  13.     public function __construct(MenuRepository $menuRepository)
  14.     {
  15.         parent::__construct();
  16.         $this->menuRepository   $menuRepository;
  17.     }
  18.     /**
  19.      * @Route("/idiom", name="idiom")
  20.      */
  21.     public function changeIdiom(){
  22.         return $this->json(['idiom' => 'ok']);
  23.     }
  24.     /**
  25.      * @Route("/", name="login")
  26.      */
  27.     public function indexAction(Request $requestAuthenticationUtils $utils)
  28.     {
  29.         if($this->getUser()){
  30.             $user=$this->getUser();
  31.         }else{
  32.             $user=new User();
  33.         }
  34.         $items=array();
  35.         $this->getMenu('home');
  36.         return $this->render('home/index.html.twig', [
  37.             'error'             => '$error',
  38.             'controller_name'   => $user->getName().' '.$user->getSurname(),
  39.             'menuprincipal'     => $this->getMenuprincipal(),
  40.             'menusecundario'    => $this->getMenusecundario(),
  41.             'menutop'           => $this->getMenutop(),
  42.             'menusubmenu'       => $this->getMenusubmenu(),
  43.         ]);
  44.     }
  45.     /**
  46.      * @Route("/logout", name="logout")
  47.      * @param Request $request
  48.      * @param AuthenticationUtils $utils
  49.      * @return \Symfony\Component\HttpFoundation\Response
  50.      */
  51.     public function logoutAction(Request $requestAuthenticationUtils $utils)
  52.     {
  53.         $error $utils->getLastAuthenticationError();
  54.         $lastUsername $utils->getLastUsername();
  55.         return $this->render('security/login.html.twig', [
  56.             'error'         => $error,
  57.             'last_username' => $lastUsername
  58.         ]);
  59.     }
  60. }