mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-06 07:49:53 +00:00
rename method newsWithDateFilter => currentNews
This commit is contained in:
parent
6787612071
commit
6da297d1d2
@ -34,9 +34,9 @@ class NewsItemApiController
|
|||||||
*/
|
*/
|
||||||
public function listCurrentNewsItems(): JsonResponse
|
public function listCurrentNewsItems(): JsonResponse
|
||||||
{
|
{
|
||||||
$total = $this->newsItemRepository->countWithDateFilter();
|
$total = $this->newsItemRepository->countCurrentNews();
|
||||||
$paginator = $this->paginatorFactory->create($total);
|
$paginator = $this->paginatorFactory->create($total);
|
||||||
$newsItems = $this->newsItemRepository->findWithDateFilter(
|
$newsItems = $this->newsItemRepository->findCurrentNews(
|
||||||
$paginator->getItemsPerPage(),
|
$paginator->getItemsPerPage(),
|
||||||
$paginator->getCurrentPage()->getFirstItemNumber()
|
$paginator->getCurrentPage()->getFirstItemNumber()
|
||||||
);
|
);
|
||||||
|
@ -80,9 +80,12 @@ class NewsItemRepository implements ObjectRepository
|
|||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findWithDateFilter($limit = null, $offset = null)
|
/**
|
||||||
|
* @return list<NewsItem>
|
||||||
|
*/
|
||||||
|
public function findCurrentNews(int $limit = null, int $offset = null): array
|
||||||
{
|
{
|
||||||
$qb = $this->buildQueryWithDateFilter();
|
$qb = $this->buildQueryCurrentNews();
|
||||||
|
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
$qb->setMaxResults($limit);
|
$qb->setMaxResults($limit);
|
||||||
@ -107,15 +110,15 @@ class NewsItemRepository implements ObjectRepository
|
|||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countWithDateFilter()
|
public function countCurrentNews()
|
||||||
{
|
{
|
||||||
return $this->buildQueryWithDateFilter()
|
return $this->buildQueryCurrentNews()
|
||||||
->select('COUNT(n)')
|
->select('COUNT(n)')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildQueryWithDateFilter(): QueryBuilder
|
private function buildQueryCurrentNews(): QueryBuilder
|
||||||
{
|
{
|
||||||
$now = $this->clock->now();
|
$now = $this->clock->now();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user