src/Controller/DefaultController.php line 17

  1. <?php
  2. namespace App\Controller;
  3. use App\Service\PassthroughService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Request;
  10. class DefaultController extends AbstractController
  11. {
  12.     /**
  13.      * @Route("", name="app_default")
  14.      */
  15.     public function index(Request $request) {
  16.         return $this->render('default/index.twig');
  17.     }
  18.     /**
  19.      * @Route("/ql", name="app_ql_index")
  20.      */
  21.     public function qualityLabelIndex(Request $request) {
  22.         return $this->render('default/ql/index.twig');
  23.     }
  24.     /**
  25.      * @Route("/ql/distributor/{command}", name="app_distributor", defaults={"command"=null})
  26.      */
  27.     public function distributor(Request $request$command) {
  28.         if($command == '') {
  29.             return $this->redirect('/default/index.twig');
  30.         }
  31.         $arguments array_merge($request->query->all(), $request->request->all());
  32.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  33.         if (!$token && $request->headers->has('Token')) {
  34.             $token $request->headers->get('Token');
  35.         }
  36.         $arguments['apiKey'] = $token;
  37.         $arguments['action'] = PassthroughService::MODULE_DISTRIBUTOR ucfirst($command);
  38.         $PassthroughService = new PassthroughService($arguments);
  39.         return $PassthroughService->handleRequest();
  40.     }
  41.     /**
  42.      * @Route("/ql/label/{command}", name="app_label", defaults={"command"=null})
  43.      */
  44.     public function label(Request $request$command) {
  45.         if($command == '') {
  46.             return $this->render('default/index.twig');
  47.         }
  48.         $arguments array_merge($request->query->all(), $request->request->all());
  49.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  50.         if (!$token && $request->headers->has('Token')) {
  51.             $token $request->headers->get('Token');
  52.         }
  53.         $arguments['apiKey'] = $token;
  54.         $arguments['action'] = PassthroughService::MODULE_LABEL ucfirst($command);
  55.         $arguments['command'] = $command;
  56.         $PassthroughService = new PassthroughService($arguments);
  57.         return $PassthroughService->handleRequest();
  58.     }
  59.     /**
  60.      * @Route("/ql/model/{command}", name="app_model", defaults={"command"=null})
  61.      */
  62.     public function model(Request $request$command) {
  63.         if($command == '') {
  64.             return $this->render('default/index.twig');
  65.         }
  66.         $arguments array_merge($request->query->all(), $request->request->all());
  67.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  68.         if (!$token && $request->headers->has('Token')) {
  69.             $token $request->headers->get('Token');
  70.         }
  71.         $arguments['apiKey'] = $token;
  72.         $arguments['action'] = PassthroughService::MODULE_MODEL ucfirst($command);
  73.         $arguments['command'] = $command;
  74.         $PassthroughService = new PassthroughService($arguments);
  75.         return $PassthroughService->handleRequest();
  76.     }
  77.     /**
  78.      * @Route("/ql/heatPumpType/{command}", name="app_heatPumpType", defaults={"command"=null})
  79.      */
  80.     public function heatPumpType(Request $request$command) {
  81.         if($command == '') {
  82.             return $this->render('default/index.twig');
  83.         }
  84.         $arguments array_merge($request->query->all(), $request->request->all());
  85.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  86.         if (!$token && $request->headers->has('Token')) {
  87.             $token $request->headers->get('Token');
  88.         }
  89.         $arguments['apiKey'] = $token;
  90.         $arguments['action'] = PassthroughService::MODULE_HEATPUMPTYPE ucfirst($command);
  91.         $arguments['command'] = $command;
  92.         $PassthroughService = new PassthroughService($arguments);
  93.         return $PassthroughService->handleRequest();
  94.     }
  95.     /**
  96.      * @Route("/ql/nationalCommission/{command}", name="app_nationalCommission", defaults={"command"=null})
  97.      */
  98.     public function nationalCommission(Request $request$command) {
  99.         if($command == '') {
  100.             return $this->render('default/index.twig');
  101.         }
  102.         $arguments array_merge($request->query->all(), $request->request->all());
  103.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  104.         if (!$token && $request->headers->has('Token')) {
  105.             $token $request->headers->get('Token');
  106.         }
  107.         $arguments['apiKey'] = $token;
  108.         $arguments['action'] = PassthroughService::MODULE_NATIONALCOMMISSON ucfirst($command);
  109.         $arguments['command'] = $command;
  110.         $PassthroughService = new PassthroughService($arguments);
  111.         return $PassthroughService->handleRequest();
  112.     }
  113.     /**
  114.      * @Route("/ql/dataShell/{command}", name="app_datashell", defaults={"command"=null})
  115.      */
  116.     public function dataShell(Request $request$command)
  117.     {
  118.         if ($command == '') {
  119.             return $this->render('default/index.twig');
  120.         }
  121.         $arguments array_merge($request->query->all(), $request->request->all());
  122.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  123.         if (!$token && $request->headers->has('Token')) {
  124.             $token $request->headers->get('Token');
  125.         }
  126.         $arguments['apiKey'] = $token;
  127.         $arguments['action'] = PassthroughService::MODULE_DATASHELL ucfirst($command);
  128.         $arguments['command'] = $command;
  129.         $PassthroughService = new PassthroughService($arguments);
  130.         return $PassthroughService->handleRequest();
  131.     }
  132.     /**
  133.      * @Route("/ql/climate/{command}", name="app_climate", defaults={"command"=null})
  134.      */
  135.     public function climate(Request $request$command)
  136.     {
  137.         if ($command == '') {
  138.             return $this->render('default/index.twig');
  139.         }
  140.         $arguments array_merge($request->query->all(), $request->request->all());
  141.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  142.         if (!$token && $request->headers->has('Token')) {
  143.             $token $request->headers->get('Token');
  144.         }
  145.         $arguments['apiKey'] = $token;
  146.         $arguments['action'] = PassthroughService::MODULE_CLIMATE ucfirst($command);
  147.         $arguments['command'] = $command;
  148.         $PassthroughService = new PassthroughService($arguments);
  149.         return $PassthroughService->handleRequest();
  150.     }
  151.     /**
  152.      * @Route("/ql/temperature/{command}", name="app_temperature", defaults={"command"=null})
  153.      */
  154.     public function temperature(Request $request$command)
  155.     {
  156.         if ($command == '') {
  157.             return $this->render('default/index.twig');
  158.         }
  159.         $arguments array_merge($request->query->all(), $request->request->all());
  160.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  161.         if (!$token && $request->headers->has('Token')) {
  162.             $token $request->headers->get('Token');
  163.         }
  164.         $arguments['apiKey'] = $token;
  165.         $arguments['action'] = PassthroughService::MODULE_TEMPERATURE ucfirst($command);
  166.         $arguments['command'] = $command;
  167.         $PassthroughService = new PassthroughService($arguments);
  168.         return $PassthroughService->handleRequest();
  169.     }
  170.     /**
  171.      * @Route("/ql/trigger", name="app_trigger")
  172.      */
  173.     public function trigger(Request $request)
  174.     {
  175.         $arguments array_merge($request->query->all(), $request->request->all());
  176.         $token = isset($arguments['token']) ? $arguments['token'] : null;
  177.         if (!$token && $request->headers->has('Token')) {
  178.             $token $request->headers->get('Token');
  179.         }
  180.         $arguments['apiKey'] = $token;
  181.         $arguments['action'] = PassthroughService::MODULE_TRIGGER;
  182.         $PassthroughService = new PassthroughService($arguments);
  183.         return $PassthroughService->handleRequest();
  184.     }
  185. }