src/Controller/Endpoint/DefaultController.php line 59

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Endpoint;
  3. use App\Controller\AbstractClass\AbstractDefaultController;
  4. use App\Repository\UserRepository;
  5. use App\Service\Access;
  6. use App\Service\AdvertisingManagement;
  7. use App\Service\ContentService;
  8. use App\Service\EmailService;
  9. use App\Service\Language;
  10. use App\Service\User as UserService;
  11. use Doctrine\ORM\EntityManagerInterface;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\RequestStack;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
  18. use Symfony\Component\Routing\RouterInterface;
  19. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  20. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  21. class DefaultController extends AbstractDefaultController
  22. {
  23.     private string $class;
  24.     private ?Request $request null;
  25.     public function __construct(AdvertisingManagement $advertiserServiceRequestStack $requestStack)
  26.     {
  27.         $this->request $requestStack->getCurrentRequest();
  28.         $advertiser $advertiserService->getCurrentAdvertiser();
  29.         $className = (new \ReflectionClass($this))->getShortName();
  30.         $this->class 'App\\Controller\\Advertiser\\Generic\\Generic' $className;
  31.         if (method_exists($advertiser'getRef') && class_exists('App\\Controller\\Advertiser\\' $advertiser '\\' $advertiser->getRef() . $className)) {
  32.             $this->class 'App\\Controller\\Advertiser\\' $advertiser '\\' $advertiser->getRef() . $className;
  33.         }
  34.     }
  35.     #[Route(path'/'name'index'methods'GET')]
  36.     public function index(Access $accessAdvertisingManagement $advertiserServiceContentService $contentServiceEntityManagerInterface $em): Response
  37.     {
  38.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  39.     }
  40.     #[Route(path'/login'name'login'methods'GET|POST')]
  41.     public function login(AuthenticationUtils $authenticationUtilsAdvertisingManagement $advertiserServiceUserService $userServiceUserPasswordHasherInterface $userPasswordHasherInterfaceRouterInterface $routerTokenStorageInterface $tokenStorage): Response
  42.     {
  43.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  44.     }
  45.     #[Route(path'/logout'name'logout'methods'GET|POST')]
  46.     public function logout(): Response
  47.     {
  48.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  49.     }
  50.     #[Route(path'/lostpassword'name'lostpassword'methods'GET|POST')]
  51.     public function lostpassword(UserRepository $repositoryEmailService $emailServiceEntityManagerInterface $em): Response
  52.     {
  53.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  54.     }
  55.     #[Route(path'/download'name'download'methods'GET')]
  56.     public function download(Access $accessEntityManagerInterface $emAdvertisingManagement $advertiserService): Response
  57.     {
  58.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  59.     }
  60.     #[Route(path'/download/{uuid}'name'download_file'methods'GET')]
  61.     public function downloadFile(EntityManagerInterface $emAccess $accessstring $uuid): Response
  62.     {
  63.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  64.     }
  65.     #[Route(path'/admin')]
  66.     public function admin(): Response
  67.     {
  68.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  69.     }
  70.     #[Route(path'/switch-language'name'switch_language'methods'GET|POST')]
  71.     public function switchLanguage(Language $languageUrlMatcherInterface $urlMatcher): Response
  72.     {
  73.         return $this->forward($this->class '::' __FUNCTION__$this->request->attributes->get('_route_params'));
  74.     }
  75. }