<?php
namespace App\Controller\Endpoint;
use App\Controller\AbstractClass\AbstractDefaultController;
use App\Repository\UserRepository;
use App\Service\Access;
use App\Service\AdvertisingManagement;
use App\Service\ContentService;
use App\Service\EmailService;
use App\Service\Language;
use App\Service\User as UserService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class DefaultController extends AbstractDefaultController
{
private string $class;
private ?Request $request = null;
public function __construct(AdvertisingManagement $advertiserService, RequestStack $requestStack)
{
$this->request = $requestStack->getCurrentRequest();
$advertiser = $advertiserService->getCurrentAdvertiser();
$className = (new \ReflectionClass($this))->getShortName();
$this->class = 'App\\Controller\\Advertiser\\Generic\\Generic' . $className;
if (method_exists($advertiser, 'getRef') && class_exists('App\\Controller\\Advertiser\\' . $advertiser . '\\' . $advertiser->getRef() . $className)) {
$this->class = 'App\\Controller\\Advertiser\\' . $advertiser . '\\' . $advertiser->getRef() . $className;
}
}
#[Route(path: '/', name: 'index', methods: 'GET')]
public function index(Access $access, AdvertisingManagement $advertiserService, ContentService $contentService, EntityManagerInterface $em): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/login', name: 'login', methods: 'GET|POST')]
public function login(AuthenticationUtils $authenticationUtils, AdvertisingManagement $advertiserService, UserService $userService, UserPasswordHasherInterface $userPasswordHasherInterface, RouterInterface $router, TokenStorageInterface $tokenStorage): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/logout', name: 'logout', methods: 'GET|POST')]
public function logout(): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/lostpassword', name: 'lostpassword', methods: 'GET|POST')]
public function lostpassword(UserRepository $repository, EmailService $emailService, EntityManagerInterface $em): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/download', name: 'download', methods: 'GET')]
public function download(Access $access, EntityManagerInterface $em, AdvertisingManagement $advertiserService): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/download/{uuid}', name: 'download_file', methods: 'GET')]
public function downloadFile(EntityManagerInterface $em, Access $access, string $uuid): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/admin')]
public function admin(): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
#[Route(path: '/switch-language', name: 'switch_language', methods: 'GET|POST')]
public function switchLanguage(Language $language, UrlMatcherInterface $urlMatcher): Response
{
return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
}
}