src/Controller/DefaultController.php line 43

Open in your IDE?
  1. <?php
  2. /**
  3.  * User: broasca
  4.  * Date: 21/01/2018
  5.  * Time: 18:57
  6.  */
  7. namespace App\Controller;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Exception;
  10. use FOS\RestBundle\Controller\AbstractFOSRestController;
  11. use FOS\RestBundle\Controller\Annotations as Rest;
  12. use JMS\Serializer\DeserializationContext;
  13. use JMS\Serializer\SerializationContext;
  14. use JMS\Serializer\SerializerInterface;
  15. use Knp\Snappy\Pdf;
  16. use Psr\Log\LoggerInterface;
  17. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  18. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  19. use Symfony\Component\HttpFoundation\JsonResponse;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use Symfony\Component\HttpKernel\KernelInterface;
  23. use Symfony\Component\PropertyAccess\PropertyAccessor;
  24. use Symfony\Component\Routing\Annotation\Route;
  25. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  26. use Symfony\Component\Security\Core\User\UserInterface;
  27. use Symfony\Contracts\Translation\TranslatorInterface;
  28. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  29. /**
  30.  * Class DefaultController
  31.  */
  32. class DefaultController extends Controller
  33. {
  34.     /**
  35.      * @Route("/", name="index")
  36.      * @Template("pages/index.html.twig")
  37.      * @param Request $request
  38.      */
  39.     public function index(Request $request)
  40.     {
  41.     }
  42.     /**
  43.      * @Route("/app", name="app")
  44.      * @Route("/app/{token}", name="app_token", requirements={"token"=".+"})
  45.      */
  46.     public function app()
  47.     {
  48.         try {
  49.             $indexPath __DIR__ '/../../public/app/index.html';
  50.             if(file_exists($indexPath)){
  51.                 return new BinaryFileResponse($indexPath);
  52.             } else {
  53.                 return new JsonResponse('Access denied');
  54.             }
  55.         } catch (\InvalidArgumentException $e) {
  56.             throw $this->createNotFoundException("File index not exists!");
  57.         }
  58.     }
  59. }