src/Action/HomeAction.php line 39

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Action;
  4. use App\Infra\Services\ApiService;
  5. use App\Responder\RedirectResponder;
  6. use App\Responder\TemplateResponder;
  7. use App\Infra\Services\FilterApiService;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\RequestStack;
  10. use Symfony\Contracts\HttpClient\HttpClientInterface;
  11. use App\Domain\Repository\Interfaces\TextRepositoryInterface;
  12. use App\Infra\Services\PopupService;
  13. use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
  14. class HomeAction extends AbstractAction
  15. {
  16.     public function __construct(
  17.         TemplateResponder $templateResponder,
  18.         RedirectResponder $redirectResponder,
  19.         PdoSessionHandler $pdoSessionHandler,
  20.         ApiService $apiService,
  21.         FilterApiService $filterApiService,
  22.         RequestStack $requestStack
  23.     )
  24.     {
  25.         parent::__construct($templateResponder$redirectResponder$requestStack);
  26.         //$this->templateResponder = $templateResponder;
  27.         //$this->redirectResponder = $redirectResponder;
  28.         $this->apiService $apiService;
  29.         $this->filterApiService $filterApiService;
  30.     }
  31.     /**
  32.      * @Route("/", name="index")
  33.      */
  34.     public function __invoke()
  35.     {
  36.         $properties $this->apiService->getAllProperties();
  37.         //$references = $this->filterApiService->getReferencesWithoutParking();
  38.         $references $this->filterApiService->getResidenceReferences();
  39.         $futurProjects $this->filterApiService->getFuturProjects();
  40.         $buildingProjects $this->filterApiService->getConstructionProjects();
  41.         $projects $this->filterApiService->getAllProjects();
  42.         // Propriétées en vente
  43.         $salesProperties $this->filterApiService->getPropertiesByCategory(1);
  44.         $projects array_reverse($projects);
  45.         $arrayOtherProperties = [];
  46.         foreach ($properties['properties'] as $property) {
  47.             if ($property['category'] == or $property['category'] == 2) {
  48.                 $arrayOtherProperties[] = [$property][0];
  49.             }
  50.         }
  51.         $popup = new PopupService($this->request);
  52.         $response $this->templateResponder->__invoke('home.html.twig', [
  53.             'properties' => $arrayOtherProperties,
  54.             'references' => $references,
  55.             'futurProjects' => $futurProjects,
  56.             'salesProperties' => array_slice($salesProperties4),
  57.             'buildingProjects' => $buildingProjects,
  58.             'projects' => $projects,
  59.             'popup2024' => $popup->showPopup()
  60.         ]);
  61.         if($popup->showPopup()) $response->headers->setCookie($popup->getCookie());
  62.         return $response;
  63.     }
  64. }