src/Controller/HomeController.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Services\ExpedienteService;
  4. use App\Services\FGJEMService;
  5. use Pimcore\Controller\FrontendController;
  6. use Pimcore\Log\ApplicationLogger;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use DateTime;
  12. use DateTimeZone;
  13. class HomeController extends FrontendController
  14. {
  15.     /**
  16.      * @var ApplicationLogger 
  17.      */
  18.     private $logger;
  19.     
  20.     public function __construct(ApplicationLogger $logger)
  21.     {
  22.         $this->logger $logger;
  23.     }
  24.     /**
  25.      * @Route("/es", name="home-index", methods={"GET"})
  26.      * 
  27.      * @param Request $request
  28.      *
  29.      * @return Response|RedirectResponse
  30.      *
  31.      * @throws \Exception
  32.      */
  33.     public function indexAction(Request $requestExpedienteService $serviceCOBUPEMFGJEMService $serviceFGJEM)
  34.     {
  35.         $cobupem = array();
  36.         $fgjem = array();
  37.         $fechaTimezone $this->convertDateFromTimezone(null'UTC''America/Mexico_City''Y-m-d');
  38.         $fechaAnterior date('d/m/Y'strtotime('-1 day'strtotime($fechaTimezone)));
  39.         $fechaActual date('d/m/Y'strtotime($fechaTimezone));
  40.         $cobupemWS $serviceCOBUPEM->obtenerRegistros('''''''''');
  41.         $fiscalia $serviceFGJEM->obtenerRegistros('''''',  ''''$fechaAnterior$fechaActual);
  42.         if ($cobupemWS) {
  43.             // $this->logger->info(json_encode($cobupemWS));
  44.             $cobupem $cobupemWS;
  45.         }
  46.         if ($fiscalia) {
  47.             // $this->logger->info(json_encode($fiscalia));
  48.             $fgjem $fiscalia;
  49.         }
  50.         return $this->render('home/index.html.twig', [
  51.             'cobupem' => $cobupem,
  52.             'fgjem' => $fgjem,
  53.         ]);
  54.     }
  55.     private function convertDateFromTimezone($date$timezone$timezone_to$format) {
  56.         $date = new DateTime($date, new DateTimeZone($timezone));
  57.         $date->setTimezone(new DateTimeZone($timezone_to));
  58.         return $date->format($format);
  59.     }
  60. }