<?phpnamespace App\Controller;use App\Controller\DefaultValuesController;//use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;use Doctrine\ODM\MongoDB\Aggregation\Aggregation;//use Doctrine\ODM\MongoDB\DocumentManager;use Doctrine\ORM\EntityManager;use Psr\Log\LoggerInterface;use Symfony\Bridge\Doctrine\ManagerRegistry;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;/** * @Route("/") */class GuardController extends AbstractController{ public static function getName() { return "Authentication"; } public static function getAdminName() { return "guard"; } /** * @var LoggerInterface */ private $logger; public function __construct( LoggerInterface $logger ) { $this->logger = $logger; $this->logger->debug($this->logPrefix(__METHOD__).' '); } /** * @Route("/login", name="app_login") */ public function login(AuthenticationUtils $authenticationUtils): Response { $this->logger->debug($this->logPrefix(__METHOD__).' '); if ($this->getUser()) { //return $this->redirectToRoute('admin_default'); return $this->render('master/guard/auth-login.html.twig'); } // get the login error if there is one $error = $authenticationUtils->getLastAuthenticationError(); // last username entered by the user $lastUsername = $authenticationUtils->getLastUsername(); return $this->render('master/guard/auth-login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); } /** * @Route("/logout", name="app_logout") */ public function logout(ManagerRegistry $managerRegistry) { $this->logger->debug($this->logPrefix(__METHOD__).' '); return $this->redirectToRoute('app_login'); /** @var EntityManager $em */ $em = $managerRegistry->getManager("master"); //throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); } private function logPrefix($message) { $limit = 70; $content = explode("::",$message); $len = $limit - strlen($content[0]); return $content[0].str_pad(' '.$content[1],$len,'.',STR_PAD_LEFT).' '; }}