<?php
declare(strict_types = 1);
namespace App\Action;
use App\Infra\Services\ApiService;
use App\Infra\Services\PopupService;
use App\Responder\RedirectResponder;
use App\Responder\TemplateResponder;
use App\Infra\Services\FilterApiService;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use App\Domain\Repository\Interfaces\TextRepositoryInterface;
class ProjectAction extends AbstractAction
{
public function __construct(
TemplateResponder $templateResponder,
RedirectResponder $redirectResponder,
FilterApiService $filterApiService,
RequestStack $requestStack
)
{
parent::__construct($templateResponder, $redirectResponder, $requestStack);
//$this->templateResponder = $templateResponder;
//$this->redirectResponder = $redirectResponder;
$this->filterApiService = $filterApiService;
}
/**
* @Route("/projets", name="projects")
*/
public function __invoke()
{
$projects = $this->filterApiService->getAllProjects();
$projects = array_reverse($projects);
$popup = new PopupService($this->request);
$response = $this->templateResponder->__invoke('project.html.twig', [
'projects' => $projects,
'popup2024' => $popup->showPopup()
]);
if($popup->showPopup()) $response->headers->setCookie($popup->getCookie());
return $response;
}
}