<?php
namespace App\Controller\Live;
use App\Entity\Sale;
use App\Repository\SaleRepository;
use Symfony\Component\HttpFoundation\Request;
/**
* Handles the screens making up the portal between vpauto.fr and the live app
* (Sorry, the gun that allows teleportation is not here).
*
* @see Controller
*/
class PortalController extends Controller
{
public function __construct(private readonly SaleRepository $saleRepository, private readonly string $livePdfGuide)
{
}
public function accessAction(Request $request)
{
return $this->render('/Live/Portal/access.html.twig', [
'guideUrl' => $this->livePdfGuide,
'sale' => $request->query->get('sale', null),
]);
}
public function nextSalesAction()
{
return $this->render('/Live/Portal/next_sales.html.twig', [
'todaysLive' => $this->saleRepository->findTodaysClosedLive(),
'sales' => $this->saleRepository->findSomeFutureLiveCompatible(3),
'guideUrl' => $this->livePdfGuide,
]);
}
public function saleHoursAction($saleId)
{
$sale = $this->saleRepository->findOneById($saleId);
if (null === $sale || null === $sale->getHours() || Sale::STATUS_CLOSED === $sale->getStatus()) {
return $this->redirect($this->generateUrl('live_portal_next_sales'));
}
return $this->render('/Live/Portal/sale_hours.html.twig', [
'sale' => $sale,
'can_suscribe' => $sale->getEndDate() > new \DateTime() && $sale->getStartDate() < date_create('+7 days'),
'guideUrl' => $this->livePdfGuide,
]);
}
public function nextSalesLiveAction()
{
return $this->render('/Live/Portal/next_sales_pro.html.twig', [
'todaysLive' => $this->saleRepository->findTodaysClosedLive(),
'sales' => $this->saleRepository->findSomeFutureLiveCompatible(3),
'guideUrl' => $this->livePdfGuide,
]);
}
}