<?php
declare(strict_types = 1);
namespace App\Action;
use App\Domain\Repository\Interfaces\TextRepositoryInterface;
use App\Infra\Services\ApiService;
use App\Infra\Services\FilterApiService;
use App\Responder\RedirectResponder;
use App\Responder\TemplateResponder;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class HomeAction extends AbstractAction
{
public function __construct(
TemplateResponder $templateResponder,
RedirectResponder $redirectResponder,
PdoSessionHandler $pdoSessionHandler,
ApiService $apiService,
FilterApiService $filterApiService
)
{
$this->templateResponder = $templateResponder;
$this->redirectResponder = $redirectResponder;
$this->apiService = $apiService;
$this->filterApiService = $filterApiService;
}
/**
* @Route("/", name="index")
*/
public function __invoke()
{
$properties = $this->apiService->getAllProperties();
$references = $this->filterApiService->getReferences();
$futurProjects = $this->filterApiService->getFuturProjects();
$buildingProjects = $this->filterApiService->getConstructionProjects();
$projects = $this->filterApiService->getAllProjects();
$arrayOtherProperties = [];
foreach ($properties['properties'] as $property) {
if ($property['category'] == 1 or $property['category'] == 2) {
$arrayOtherProperties[] = [$property][0];
}
}
return $this->templateResponder->__invoke('home.html.twig', [
'properties' => $arrayOtherProperties,
'references' => $references,
'futurProjects' => $futurProjects,
'buildingProjects' => $buildingProjects,
'projects' => $projects,
]);
}
}