src/Controller/DefaultController.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use App\Service\AppService;
  7. use App\Form\WhitelistType;
  8. class DefaultController extends BaseController
  9. {
  10.     private $_doctrine;
  11.     private $_appService;
  12.     
  13.     public function __construct(
  14.             ManagerRegistry $doctrine,
  15.             AppService $appService)
  16.     {
  17.         $this->_doctrine $doctrine;
  18.         $this->_appService $appService;
  19.     }
  20.     public function index()
  21.     {
  22.         if ($this->_appService->isMobileApp())
  23.             $view 'Default/mobileIndex.html.twig';
  24.         else
  25.             $view 'Default/index.html.twig';
  26.         
  27.         return $this->render($view);
  28.     }
  29.     
  30.     public function whitelistPopupAjax(Request $request)
  31.     {
  32.         $form $this->createForm(WhitelistType::class);
  33.         $form->handleRequest($request);
  34.         if ($form->isSubmitted())
  35.         {
  36.             if ($form->isValid())
  37.             {
  38.                 $em $this->_doctrine->getManager();
  39.                 $em->persist($form->getData());
  40.                 $em->flush();
  41.                 
  42.                 $form $this->createForm(WhitelistType::class);
  43.                 
  44.                 $status true;
  45.             }
  46.             
  47.             return new JsonResponse(array(
  48.                 'html' => $this->renderView('Default/partials/whitelistPopupForm.html.twig', array(
  49.                     'form' => $form->createView(),
  50.                     'status' => $status ?? false
  51.                 ))
  52.             ));
  53.         }
  54.         
  55.         return new JsonResponse(array(
  56.             'html' => $this->renderView('Default/whitelistPopup.html.twig', array(
  57.                 'form' => $form->createView()
  58.             ))
  59.         ));
  60.     }
  61.     
  62.     public function tokenAction()
  63.     {
  64.         return $this->render('Token/tokenPage.html.twig',[]);
  65.     }
  66. }