<?php
namespace App\Controller\Website;
use App\Repository\ArticlesRepository;
use Sulu\Component\Rest\RequestParametersTrait;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
class ArticlesController extends AbstractController
{
use RequestParametersTrait;
private $twig;
private $ap;
public function __construct(Environment $twig, ArticlesRepository $ap)
{
$this->twig = $twig;
$this->ap = $ap;
}
/**
* Trouve les articles selon un tag donné
*
* @return Response
*/
public function getArticlesByTagAction(Request $req): Response
{
$request = $this->ap->getArticlesByTag($req);
$res = new Response($this->twig->render('articles/articlesByTag.html.twig', ['request' => $request]));
return $res;
}
public function getAllAlauneArticles(Request $req): Response
{
$thematiques = $this->getRequestParameter($req, 'thematiques', false, '');
$request = $this->ap->getAlauneArticles($thematiques);
$res = new Response($this->twig->render('homepage-articles/alaune.html.twig', ['request' => $request]));
return $res;
}
public function getIncomingEvents(): Response
{
$request = $this->ap->getIncomingEvents();
$res = new Response($this->twig->render('homepage-articles/evenementsavenir.html.twig', ['hits' => $request]));
return $res;
}
}