mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 00:55:01 +00:00
Improve layout of the history page
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\NewsItem;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\NewsItemRepository;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
@@ -19,6 +20,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Twig\Environment;
|
||||
|
||||
class NewsItemHistoryController extends AbstractController
|
||||
{
|
||||
@@ -26,42 +28,41 @@ class NewsItemHistoryController extends AbstractController
|
||||
private readonly NewsItemRepository $newsItemRepository,
|
||||
private readonly PaginatorFactory $paginatorFactory,
|
||||
private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory,
|
||||
private readonly Environment $environment,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/news-items/history", name="chill_main_news_items_history")
|
||||
*/
|
||||
public function listAction(Request $request): Response
|
||||
public function list(): Response
|
||||
{
|
||||
$filter = $this->buildFilterOrder(false);
|
||||
$filter = $this->buildFilterOrder();
|
||||
$total = $this->newsItemRepository->countAllFilteredBySearchTerm($filter->getQueryString());
|
||||
$newsItems = $this->newsItemRepository->findAllFilteredBySearchTerm($filter->getQueryString());
|
||||
|
||||
$pagination = $this->paginatorFactory->create($total);
|
||||
|
||||
return $this->render('@ChillMain/NewsItem/news_items_history.html.twig', [
|
||||
return new Response($this->environment->render('@ChillMain/NewsItem/news_items_history.html.twig', [
|
||||
'entities' => $newsItems,
|
||||
'paginator' => $pagination,
|
||||
'filter_order' => $filter,
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/news-items/{id}", name="chill_main_single_news_item")
|
||||
*/
|
||||
public function showSingleItem(int $id, Request $request): Response
|
||||
public function showSingleItem(NewsItem $newsItem, Request $request): Response
|
||||
{
|
||||
$newsItem = $this->newsItemRepository->findOneBy(['id' => $id]);
|
||||
|
||||
return $this->render(
|
||||
return new Response($this->environment->render(
|
||||
'@ChillMain/NewsItem/show.html.twig',
|
||||
[
|
||||
'entity' => $newsItem,
|
||||
]
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
private function buildFilterOrder($includeFilterByUser = true, $includeMissionType = false): FilterOrderHelper
|
||||
private function buildFilterOrder(): FilterOrderHelper
|
||||
{
|
||||
$filterBuilder = $this->filterOrderHelperFactory
|
||||
->create(self::class)
|
||||
|
Reference in New Issue
Block a user