src/Action/Ajax/SearchFormAction.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Action\Ajax;
  4. use App\Domain\Repository\Interfaces\JobRepositoryInterface;
  5. use App\Infra\Services\FilterApiService;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Twig\Environment;
  11. class SearchFormAction
  12. {
  13.     public function __construct(
  14.         FilterApiService $filterApiService,
  15.         Environment $environment
  16.     )
  17.     {
  18.         $this->filterApiService $filterApiService;
  19.         $this->environnement $environment;
  20.     }
  21.     /**
  22.      * @Route("/form/search", name="form-search", methods={"GET"})
  23.      */
  24.     public function __invoke(Request $request)
  25.     {
  26.         $regions = [];
  27.         $properties $this->filterApiService->getPropertiesForCities();
  28.         foreach ($properties as $property) {
  29. //                $regions[] = $property['region']['name'];
  30.                 $regions[$property['city']['name']] = $property['city']['name'];
  31.               if ( $property['district'] !== null) {
  32.                  $regions[$property['district']['name']] = $property['district']['name'];
  33.               }
  34.         }
  35.         $regions = ['' => 'Tous'] + $regions;
  36.         ksort($regions);
  37.         $regions array_unique($regions);
  38.       
  39.         return new  JsonResponse($regions200);
  40.     }
  41. }