mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
process review
This commit is contained in:
@@ -16,12 +16,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
|
||||
class NewsItemRepository implements ObjectRepository
|
||||
{
|
||||
private readonly EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, private ClockInterface $clock)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(NewsItem::class);
|
||||
}
|
||||
@@ -58,6 +59,9 @@ class NewsItemRepository implements ObjectRepository
|
||||
|
||||
public function findWithDateFilter()
|
||||
{
|
||||
dump($this->buildQueryWithDateFilter()
|
||||
->getQuery()
|
||||
->getResult());
|
||||
return $this->buildQueryWithDateFilter()
|
||||
->getQuery()
|
||||
->getResult();
|
||||
@@ -73,13 +77,13 @@ class NewsItemRepository implements ObjectRepository
|
||||
|
||||
public function buildQueryWithDateFilter(): QueryBuilder
|
||||
{
|
||||
$now = new \DateTime('now');
|
||||
$now = $this->clock->now();
|
||||
|
||||
$qb = $this->createQueryBuilder('n');
|
||||
$qb
|
||||
->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->gte('n.startDate', ':now'),
|
||||
$qb->expr()->lte('n.startDate', ':now'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->lt('n.endDate', ':now'),
|
||||
$qb->expr()->isNull('n.endDate')
|
||||
|
Reference in New Issue
Block a user