src/Controller/Endpoint/TestController.php line 57

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Endpoint;
  3. use App\Controller\AbstractClass\AbstractTestController;
  4. use App\Service\AdvertisingManagement;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\RequestStack;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. /**
  10.  * Class TestController
  11.  */
  12. #[Route(path: '/test')]
  13. class TestController extends AbstractTestController
  14. {
  15.     private string $class;
  16.     private ?Request $request = null;
  17.     public function __construct(AdvertisingManagement $advertiserService, RequestStack $requestStack)
  18.     {
  19.         $this->request = $requestStack->getCurrentRequest();
  20.         $advertiser = $advertiserService->getCurrentAdvertiser();
  21.         $className = (new \ReflectionClass($this))->getShortName();
  22.         $this->class = 'App\\Controller\\Advertiser\\Generic\\Generic' . $className;
  23.         if (method_exists($advertiser, 'getRef') && class_exists('App\\Controller\\Advertiser\\' . $advertiser . '\\' . $advertiser->getRef() . $className)) {
  24.             $this->class = 'App\\Controller\\Advertiser\\' . $advertiser . '\\' . $advertiser->getRef() . $className;
  25.         }
  26.     }
  27.     #[Route(path: '/', name: 'test_index', methods: 'GET|POST')]
  28.     public function index(): Response
  29.     {
  30.         return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
  31.     }
  32.     #[Route(path: '/api/testcall', name: 'test_api_test_call', methods: 'GET|POST')]
  33.     public function testCall(): Response
  34.     {
  35.         return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
  36.     }
  37.     #[Route(path: '/api/testcallpost', name: 'test_api_test_callpost', methods: 'GET|POST')]
  38.     public function testCallPost(): Response
  39.     {
  40.         return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
  41.     }
  42.     #[Route(path: '/api/testcallpfm', name: 'test_api_test_call_pfm', methods: 'GET|POST')]
  43.     public function testCallPfm(): Response
  44.     {
  45.         return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
  46.     }
  47.     #[Route(path: '/api/testcallnotifyagency/{id}', name: 'test_api_test_callnotifyagency', methods: 'GET|POST')]
  48.     public function testCallNotifyAgency(): Response
  49.     {
  50.         return $this->forward($this->class . '::' . __FUNCTION__, $this->request->attributes->get('_route_params'));
  51.     }
  52. }