mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 15:29:50 +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
|
||||
{
|
||||
$total = $this->newsItemRepository->countWithDateFilter();
|
||||
$total = $this->newsItemRepository->countCurrentNews();
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
$newsItems = $this->newsItemRepository->findWithDateFilter(
|
||||
$newsItems = $this->newsItemRepository->findCurrentNews(
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPage()->getFirstItemNumber()
|
||||
);
|
||||
|
@ -80,9 +80,12 @@ class NewsItemRepository implements ObjectRepository
|
||||
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) {
|
||||
$qb->setMaxResults($limit);
|
||||
@ -107,15 +110,15 @@ class NewsItemRepository implements ObjectRepository
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countWithDateFilter()
|
||||
public function countCurrentNews()
|
||||
{
|
||||
return $this->buildQueryWithDateFilter()
|
||||
return $this->buildQueryCurrentNews()
|
||||
->select('COUNT(n)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function buildQueryWithDateFilter(): QueryBuilder
|
||||
private function buildQueryCurrentNews(): QueryBuilder
|
||||
{
|
||||
$now = $this->clock->now();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user