src/Controller/DefaultController.php line 17
<?php
namespace App\Controller;
use App\Service\PassthroughService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends AbstractController
{
/**
* @Route("", name="app_default")
*/
public function index(Request $request) {
return $this->render('default/index.twig');
}
/**
* @Route("/ql", name="app_ql_index")
*/
public function qualityLabelIndex(Request $request) {
return $this->render('default/ql/index.twig');
}
/**
* @Route("/ql/distributor/{command}", name="app_distributor", defaults={"command"=null})
*/
public function distributor(Request $request, $command) {
if($command == '') {
return $this->redirect('/default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_DISTRIBUTOR . ucfirst($command);
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/label/{command}", name="app_label", defaults={"command"=null})
*/
public function label(Request $request, $command) {
if($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_LABEL . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/model/{command}", name="app_model", defaults={"command"=null})
*/
public function model(Request $request, $command) {
if($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_MODEL . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/heatPumpType/{command}", name="app_heatPumpType", defaults={"command"=null})
*/
public function heatPumpType(Request $request, $command) {
if($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_HEATPUMPTYPE . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/nationalCommission/{command}", name="app_nationalCommission", defaults={"command"=null})
*/
public function nationalCommission(Request $request, $command) {
if($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_NATIONALCOMMISSON . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/dataShell/{command}", name="app_datashell", defaults={"command"=null})
*/
public function dataShell(Request $request, $command)
{
if ($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_DATASHELL . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/climate/{command}", name="app_climate", defaults={"command"=null})
*/
public function climate(Request $request, $command)
{
if ($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_CLIMATE . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/temperature/{command}", name="app_temperature", defaults={"command"=null})
*/
public function temperature(Request $request, $command)
{
if ($command == '') {
return $this->render('default/index.twig');
}
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_TEMPERATURE . ucfirst($command);
$arguments['command'] = $command;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
/**
* @Route("/ql/trigger", name="app_trigger")
*/
public function trigger(Request $request)
{
$arguments = array_merge($request->query->all(), $request->request->all());
$token = isset($arguments['token']) ? $arguments['token'] : null;
if (!$token && $request->headers->has('Token')) {
$token = $request->headers->get('Token');
}
$arguments['apiKey'] = $token;
$arguments['action'] = PassthroughService::MODULE_TRIGGER;
$PassthroughService = new PassthroughService($arguments);
return $PassthroughService->handleRequest();
}
}