src/Controller/ScanController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use JMS\DiExtraBundle\Annotation as DI;
  4. //use JMS\Payment\CoreBundle\Entity\Payment;
  5. //use JMS\Payment\CoreBundle\PluginController\Result;
  6. //use JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException;
  7. //use JMS\Payment\CoreBundle\Plugin\Exception\Action\VisitUrl;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  10. use Symfony\Component\HttpFoundation\RedirectResponse;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
  16. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  17. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  18. use App\Repository\EventsRepository;
  19. use App\Entity\Orders;
  20. use App\Entity\OrderItems;
  21. use App\Entity\OrderTickets;
  22. use App\Entity\Events;
  23. use App\Entity\EventDates;
  24. use App\Entity\EventTickets;
  25. use App\Entity\EventExtra;
  26. use App\Entity\Sites;
  27. use App\Entity\Language;
  28. use App\Entity\Coupons;
  29. use App\Entity\StatsUsers;
  30. //use Yectep\PhpSpreadsheetBundle\Factory;
  31. /**
  32.  * @Route("/",
  33.  *     name="scan_base",
  34.  *     condition="request.headers.get('Host') matches '/scan\./i'"
  35.  * )
  36.  */
  37. class ScanController extends Controller {
  38.     
  39.     /**
  40.      * @Route("/", name = "scan_home")
  41.      */
  42.     public function homeAction(Request $request) {
  43.         $domain $request->headers->get('Host');
  44.         //return new JsonResponse(array("domain"=>$domain));
  45.         return $this->render("scan/index.html.twig",array("event"=>""));
  46.     }
  47.     
  48.     /**
  49.      * @Route("/scan/list", name = "scan_list")
  50.      */
  51.     public function listAction(Request $request) {
  52.         //$domain = $request->headers->get('Host');
  53.         //return new JsonResponse(array("domain"=>$domain));
  54.     }
  55.     
  56.     /**
  57.      * @Route("/scan/login", name = "scan_login")
  58.      */
  59.     public function loginAction(Request $requestAuthenticationUtils $authenticationUtils) {
  60.         
  61.         //$username = $request->request->get('username');
  62.         $code $request->request->get('code');
  63.         
  64.         $manager $this->getDoctrine()->getManager();        
  65.         $repo $manager->getRepository(StatsUsers::class);
  66.         $result $repo->findOneByCode($code);
  67.         
  68.         if(!($result instanceof StatsUsers)) {
  69.             return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
  70.         }        
  71.         if(false === $result->getScanAccess()) {
  72.             return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
  73.         }
  74.         if(false === $result->getIsActive()) {
  75.             return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
  76.         }
  77.         // We have a user object and its active AND has scan access...
  78.         // However, if the user has no API key, its no use, so check for it!
  79.         if(false === ($api $result->getApiKey())) {
  80.             return new JsonResponse(array("result"=>false,"message"=>"UNAUTHORIZED","level"=>"error"));
  81.         }
  82.         
  83.         // We've also got an API key, now we're getting somewhere....
  84.         
  85.         $responseData = array(
  86.             'key' => $api->getKey(),
  87.             'result' => true,
  88.         );
  89.         
  90.         return new JsonResponse($responseData);
  91.     }
  92.     
  93.     /**
  94.      * @Route("/scan/{event}", name = "scan_event")
  95.      */
  96.     public function scanAction(Request $requestEvents $event) {
  97.         $dates $event->getDates();
  98.         return new JsonResponse(array(
  99.                'dates' => $dates->toArray()
  100.         ));
  101.     }
  102.     
  103.     /**
  104.      * @Route("/scan/{event}/{eventdate}", name = "scan_event_date")
  105.      */
  106.     public function scanDateAction(Request $requestEvents $eventEventDates $eventdate) {
  107.         return $this->render("scan/index.html.twig",array("event"=>$event,"eventdate"=>$eventdate));
  108.     }
  109.     
  110.     /**
  111.      * @Route("/scan/logout", name = "scan_logout")
  112.      */
  113.     public function logoutAction(Request $request) {
  114.         
  115.     }
  116. }