src/Controller/Front/HomeController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Repository\ContentRepository;
  4. use App\Repository\SliderHeaderRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Contracts\HttpClient\HttpClientInterface;
  9. class HomeController extends AbstractController
  10. {
  11.     const API_LINK 'https://middleware-production.easy2pilot-v8.com/api/';
  12.     /**
  13.      * @var HttpClientInterface
  14.      */
  15.     private HttpClientInterface $httpClient;
  16.     public function __construct(HttpClientInterface $httpClient)
  17.     {
  18.         $this->httpClient $httpClient;
  19.     }
  20.     /**
  21.      * @Route("/", name="front_home")
  22.      */
  23.     public function home(ContentRepository $contentRepositorySliderHeaderRepository $sliderHeaderRepository)
  24.     {
  25.         return $this->render('front/home.html.twig', [
  26.             'content_header' => $contentRepository->findOneBy(['page' => 'home''section' => 'header']),
  27.             'content_sale' => $contentRepository->findOneBy(['page' => 'home''section' => 'sale']),
  28.             'content_rent' => $contentRepository->findOneBy(['page' => 'home''section' => 'rent']),
  29.             'slider' => $sliderHeaderRepository->findOneBy(['page' => 'accueil']),
  30.         ]);
  31.     }
  32.     private function getToken()
  33.     {
  34.         $response $this->httpClient->request(
  35.             Request::METHOD_POST,
  36.             self::API_LINK $this->getParameter('api_uuid').'/token', [
  37.                 'headers' => [
  38.                     'login' => $this->getParameter('api_login'),
  39.                     'password' => $this->getParameter('api_password'),
  40.                 ],
  41.             ]
  42.         );
  43.         return $response->toArray()['data']['token'];
  44.     }
  45. }