<?php
namespace App\Controller;
use App\Entity\Spot;
use App\Repository\ApproachRepository;
use App\Repository\SpotRepository;
use App\Service\ApproachService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class SpotController extends AbstractController
{
private SpotRepository $spotRepository;
private ApproachRepository $approachRepository;
/**
* @param SpotRepository $spotRepository
* @param ApproachRepository $approachRepository
*/
public function __construct(SpotRepository $spotRepository, ApproachRepository $approachRepository)
{
$this->spotRepository = $spotRepository;
$this->approachRepository = $approachRepository;
}
public function index(Request $request): Response {
$response = new Response();
/** @var Spot $spot */
$spot = $this->spotRepository->findOneBy(['code' => 'marincev-gric']);
$lastApproachForUsers = $this->approachRepository->findLastForUserAndSpot($spot->getId());
$princPlanincCookie = $request->cookies->get(ApproachService::PRINCPLANINC_COOKIE);
$content = $this->renderView('spot/spot.html.twig', [
'data' => $lastApproachForUsers,
'cookie' => $princPlanincCookie,
'spot' => $spot
]);
return $response->setContent($content);
}
}