<?php
namespace App\Controller;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class accueilController extends AbstractController
{
private $client;
public function __construct(HttpClientInterface $client)
{
$this->client = $client;
}
/**
* @Route("/")
*/
public function renderAccueilPage()
{
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}articles?limit=200"
);
$content = $response->toArray()["articles"];
return $this->render('./accueil/accueil.html.twig', array(
"articles" => $content
));
}
/**
* @Route("/jacob/pages")
*/
public function renderListPages()
{
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}admin/pages?limit=6"
);
$content = $response->toArray()["pages"];
return $this->render('./accueil/pages.html.twig', array(
"pages" => $content
));
}
/**
* @Route("/forgot/{token}")
*/
public function renderModificationPassword(string $token)
{
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}articles?limit=6"
);
$content = $response->toArray()["articles"];
return $this->render(
'/accueil/accueil.html.twig', array(
'token' => $token,
"articles" => $content
)
);
}
/**
* @Route("/confirmation_email/{mail}")
*/
public function renderConfirmationEmail(string $mail, Request $request)
{
$response = $this->client->request(
'GET',
"{$_ENV['BASE_API']}articles?limit=6"
);
if (count($response->toArray()) > 0){
$content = $response->toArray()["articles"];
} else {
$content = array();
}
if ($request->query->get('token')) {
$token = $request->query->get('token');
} else {
$token = "";
}
return $this->render(
'/accueil/accueil.html.twig', array(
'tokenEmail' => $token,
'mailConfirmation' => $mail,
"articles" => $content
)
);
}
}
?>