src/Controller/accueilController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Contracts\HttpClient\HttpClientInterface;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. class accueilController extends AbstractController
  9. {
  10.     private $client;
  11.     public function __construct(HttpClientInterface $client)
  12.     {
  13.         $this->client $client;
  14.     }
  15.     
  16.     /**
  17.      * @Route("/")
  18.      */
  19.     public function renderAccueilPage()
  20.     {
  21.         $response $this->client->request(
  22.             'GET',
  23.             "{$_ENV['BASE_API']}articles?limit=200"
  24.         );
  25.         $content $response->toArray()["articles"];
  26.         return $this->render('./accueil/accueil.html.twig', array(
  27.             "articles" => $content
  28.         ));
  29.         
  30.     }
  31.     
  32.     /**
  33.      * @Route("/jacob/pages")
  34.      */
  35.     public function renderListPages()
  36.     {
  37.         $response $this->client->request(
  38.             'GET',
  39.             "{$_ENV['BASE_API']}admin/pages?limit=6"
  40.         );
  41.         $content $response->toArray()["pages"];
  42.         return $this->render('./accueil/pages.html.twig', array(
  43.             "pages" => $content
  44.         ));
  45.         
  46.     }
  47.     /**
  48.      * @Route("/forgot/{token}")
  49.      */
  50.     public function renderModificationPassword(string $token)
  51.     { 
  52.         $response $this->client->request(
  53.             'GET',
  54.             "{$_ENV['BASE_API']}articles?limit=6"
  55.         );
  56.         $content $response->toArray()["articles"];
  57.         return $this->render(
  58.             '/accueil/accueil.html.twig', array(
  59.                 'token' => $token,
  60.                 "articles" => $content
  61.             )
  62.         );
  63.     }
  64.      /**
  65.      * @Route("/confirmation_email/{mail}")
  66.      */
  67.     public function renderConfirmationEmail(string $mailRequest $request)
  68.     { 
  69.         $response $this->client->request(
  70.             'GET',
  71.             "{$_ENV['BASE_API']}articles?limit=6"
  72.         );
  73.         if (count($response->toArray()) > 0){
  74.         $content $response->toArray()["articles"];
  75.         } else {
  76.             $content = array();
  77.         }
  78.         if ($request->query->get('token')) {
  79.             $token $request->query->get('token');
  80.         } else {
  81.             $token "";
  82.         }
  83.         return $this->render(
  84.             '/accueil/accueil.html.twig', array(
  85.                 'tokenEmail' => $token,
  86.                 'mailConfirmation' => $mail,
  87.                 "articles" => $content
  88.             )
  89.         );
  90.     }
  91. }
  92. ?>