<?php
namespace App\Controller;
use App\Entity\User;
use App\Enum\SiteEnum;
use App\Kernel;
use App\Repository\PointsCatalog\CatalogOrderRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
* @Route("/admin")
*/
class AdminController extends AbstractController
{
/**
* @Route("/login", name="admin_login")
*/
public function login(AuthenticationUtils $authenticationUtils, Request $request): Response
{
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('admin/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
/**
* @Route("/test-email-template", name="admin_test_email_template")
*/
public function testEmailTemplate(KernelInterface $kernel, CatalogOrderRepository $catalogOrderRepository): Response
{
if (Kernel::DEV_ENV !== $kernel->getEnvironment()) {
throw $this->createAccessDeniedException();
}
$order = $catalogOrderRepository->find(992);
return $this->render('mails/catalog_gift_orders/notify_provider_catalog_gift_order_created_by_garage.html.twig', [
'order' => $order,
'admin_name' => 'n',
]);
}
/**
* @Route("/after-logout", name="admin_after_logout")
*/
public function afterLogout(ParameterBagInterface $pb, Request $request): RedirectResponse
{
$url = $pb->get('old_frontend_uri_es');
if (SiteEnum::SITE_STR_PT === $request->getLocale()) {
$url = $pb->get('old_frontend_uri_pt');
}
return $this->redirect($url);
}
}