src/Controller/DefaultController.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\UtilidadService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Dotenv\Dotenv;
  10. class DefaultController extends AbstractController
  11. {
  12.     private $serviceUtiles;
  13.     public function __construct(UtilidadService $serviceUtiles){
  14.         $this->serviceUtiles $serviceUtiles;
  15.     }
  16.     /**
  17.      * @Route("/administracion", name="default")
  18.      */
  19.     public function indexAdministracion()
  20.     {
  21.         return $this->render('administracion/index.html');
  22.     }
  23.     /**
  24.      * @Route("/download", name="forbbiden")
  25.      */
  26.     public function forbbiden()
  27.     {
  28.         return $this->render('default/forbbiden.html.twig');
  29.     }
  30.     /**
  31.      * @Route("/", name="raiz")
  32.      */
  33.     public function default()
  34.     {
  35.         return $this->render('default/index.html');
  36.     }
  37.     /* *** *** Version *** *** */
  38.     /**
  39.      * @Route("extra/version", name="version")
  40.      */
  41.     public function checkVersion(Request $request)
  42.     {
  43.         $dotenv = new Dotenv();
  44.         $dotenv->load('../.env');
  45.         $version $request->get("version");
  46. //        apache_setenv('no-gzip', 1); ini_set('zlib.output_compression', 0);
  47.         if($version $_ENV['VERSION']){
  48.             $fileName basename('buildv'.$_ENV['VERSION'].'.zip');
  49.             $nombreFicheroDescagado 'UrkiSystem_v'.$_ENV['VERSION'].'.zip';
  50.             //dd($fileName);
  51.             $filePath './versiones/'.$fileName;
  52.             if(!empty($fileName) && file_exists($filePath)){
  53.                 $response = new BinaryFileResponse($filePath);
  54.                 $response->headers->set('Cache-Control''public');
  55.                 $response->headers->set('Content-Disposition''attachment; filename="'.$nombreFicheroDescagado.'"');
  56.                 $response->headers->set('Content-Type''text/plain');
  57.                 return $response;
  58.             }else{
  59.                 //echo 'The file does not exist.';
  60.                 return  new Response('The file does not exist.',Response::HTTP_OK);
  61.             }
  62.         }else{
  63.             return  new Response('true',Response::HTTP_OK);
  64.         }
  65.     }
  66.     /**
  67.      * @Route ("extra/bienvenida")
  68.      */
  69.     public function bienvenida()
  70.     {
  71.         return $this->render('mail/mailOlvidoPassword.html.twig',['name'=>'Daniel']);
  72.     }
  73. }