<?php
namespace App\Controller;
use App\Entity\Menu;
use App\Entity\User;
use App\Repository\MenuRepository;
use App\Repository\PaginaRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends BaseController {
public $menuRepository;
public function __construct(MenuRepository $menuRepository)
{
parent::__construct();
$this->menuRepository = $menuRepository;
}
/**
* @Route("/idiom", name="idiom")
*/
public function changeIdiom(){
return $this->json(['idiom' => 'ok']);
}
/**
* @Route("/", name="login")
*/
public function indexAction(Request $request, AuthenticationUtils $utils)
{
if($this->getUser()){
$user=$this->getUser();
}else{
$user=new User();
}
$items=array();
$this->getMenu('home');
return $this->render('home/index.html.twig', [
'error' => '$error',
'controller_name' => $user->getName().' '.$user->getSurname(),
'menuprincipal' => $this->getMenuprincipal(),
'menusecundario' => $this->getMenusecundario(),
'menutop' => $this->getMenutop(),
'menusubmenu' => $this->getMenusubmenu(),
]);
}
/**
* @Route("/logout", name="logout")
* @param Request $request
* @param AuthenticationUtils $utils
* @return \Symfony\Component\HttpFoundation\Response
*/
public function logoutAction(Request $request, AuthenticationUtils $utils)
{
$error = $utils->getLastAuthenticationError();
$lastUsername = $utils->getLastUsername();
return $this->render('security/login.html.twig', [
'error' => $error,
'last_username' => $lastUsername
]);
}
}