src/Controller/Live/PortalController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Live;
  3. use App\Entity\Sale;
  4. use App\Repository\SaleRepository;
  5. use Symfony\Component\HttpFoundation\Request;
  6. /**
  7.  * Handles the screens making up the portal between vpauto.fr and the live app
  8.  * (Sorry, the gun that allows teleportation is not here).
  9.  *
  10.  * @see Controller
  11.  */
  12. class PortalController extends Controller
  13. {
  14.     public function __construct(private readonly SaleRepository $saleRepository, private readonly string $livePdfGuide)
  15.     {
  16.     }
  17.     public function accessAction(Request $request)
  18.     {
  19.         return $this->render('/Live/Portal/access.html.twig', [
  20.             'guideUrl' => $this->livePdfGuide,
  21.             'sale' => $request->query->get('sale'null),
  22.         ]);
  23.     }
  24.     public function nextSalesAction()
  25.     {
  26.         return $this->render('/Live/Portal/next_sales.html.twig', [
  27.             'todaysLive' => $this->saleRepository->findTodaysClosedLive(),
  28.             'sales' => $this->saleRepository->findSomeFutureLiveCompatible(3),
  29.             'guideUrl' => $this->livePdfGuide,
  30.         ]);
  31.     }
  32.     public function saleHoursAction($saleId)
  33.     {
  34.         $sale $this->saleRepository->findOneById($saleId);
  35.         if (null === $sale || null === $sale->getHours() || Sale::STATUS_CLOSED === $sale->getStatus()) {
  36.             return $this->redirect($this->generateUrl('live_portal_next_sales'));
  37.         }
  38.         return $this->render('/Live/Portal/sale_hours.html.twig', [
  39.             'sale' => $sale,
  40.             'can_suscribe' => $sale->getEndDate() > new \DateTime() && $sale->getStartDate() < date_create('+7 days'),
  41.             'guideUrl' => $this->livePdfGuide,
  42.         ]);
  43.     }
  44.     public function nextSalesLiveAction()
  45.     {
  46.         return $this->render('/Live/Portal/next_sales_pro.html.twig', [
  47.             'todaysLive' => $this->saleRepository->findTodaysClosedLive(),
  48.             'sales' => $this->saleRepository->findSomeFutureLiveCompatible(3),
  49.             'guideUrl' => $this->livePdfGuide,
  50.         ]);
  51.     }
  52. }