src/Action/HomeAction.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Action;
  4. use App\Domain\Repository\Interfaces\TextRepositoryInterface;
  5. use App\Infra\Services\ApiService;
  6. use App\Infra\Services\FilterApiService;
  7. use App\Responder\RedirectResponder;
  8. use App\Responder\TemplateResponder;
  9. use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Contracts\HttpClient\HttpClientInterface;
  12. class HomeAction extends AbstractAction
  13. {
  14.     public function __construct(
  15.         TemplateResponder $templateResponder,
  16.         RedirectResponder $redirectResponder,
  17.         PdoSessionHandler $pdoSessionHandler,
  18.         ApiService $apiService,
  19.         FilterApiService $filterApiService
  20.     )
  21.     {
  22.         $this->templateResponder $templateResponder;
  23.         $this->redirectResponder $redirectResponder;
  24.         $this->apiService $apiService;
  25.         $this->filterApiService $filterApiService;
  26.     }
  27.     /**
  28.      * @Route("/", name="index")
  29.      */
  30.     public function __invoke()
  31.     {
  32.         $properties $this->apiService->getAllProperties();
  33.         $references $this->filterApiService->getReferences();
  34.         $futurProjects $this->filterApiService->getFuturProjects();
  35.         $buildingProjects $this->filterApiService->getConstructionProjects();
  36.         $projects $this->filterApiService->getAllProjects();
  37.         $arrayOtherProperties = [];
  38.         foreach ($properties['properties'] as $property) {
  39.             if ($property['category'] == or $property['category'] == 2) {
  40.                 $arrayOtherProperties[] = [$property][0];
  41.             }
  42.         }
  43.         return $this->templateResponder->__invoke('home.html.twig', [
  44.             'properties' => $arrayOtherProperties,
  45.             'references' => $references,
  46.             'futurProjects' => $futurProjects,
  47.             'buildingProjects' => $buildingProjects,
  48.             'projects' => $projects,
  49.         ]);
  50.     }
  51. }