src/Action/PropertyAction.php line 61

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\Routing\Annotation\Route;
  10. use Symfony\Contracts\HttpClient\HttpClientInterface;
  11. class PropertyAction extends AbstractAction
  12. {
  13.     public function __construct(
  14.         TemplateResponder $templateResponder,
  15.         RedirectResponder $redirectResponder,
  16.         FilterApiService $apiService
  17.     )
  18.     {
  19.         $this->templateResponder $templateResponder;
  20.         $this->redirectResponder $redirectResponder;
  21.         $this->apiService $apiService;
  22.     }
  23.     /**
  24.      * @Route("/biens/{keyword}", defaults={"keyword" = null}, name="properties")
  25.      */
  26.     public function __invoke(?string $keyword)
  27.     {
  28.         if (!$keyword) {
  29.             $keyword 'all';
  30.         }
  31.         $idCategory $this->apiService->getInversePropertyCategory(ucfirst($keyword));
  32.         $properties $this->apiService->getPropertiesByCategory($idCategory);
  33.         $saleProperties = [];
  34.         foreach ($properties as $property) {
  35.             //if ($property['category'] == 1 or $property['category'] == 2) {
  36.                 $saleProperties[] = [$property][0];
  37.             //}
  38.         }
  39.         
  40.         if ($idCategory === 1) {
  41.             $idCategory 2;
  42.         } else {
  43.             $idCategory 1;
  44.         }
  45.         $otherProperties $this->apiService->getPropertiesByCategory($idCategory);
  46.         $arrayOtherProperties = [];
  47.         foreach ($otherProperties as $property) {
  48.             if ($property['construction']['construction_step'] != 3) {
  49.                 $arrayOtherProperties[] = [$property][0];
  50.             }
  51.         }
  52.         return $this->templateResponder->__invoke('property.html.twig', [
  53.             'properties' => $properties,
  54.             'otherProperties' => array_slice($arrayOtherProperties3)
  55.         ]);
  56.     }
  57. }