*/ class EventRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Event::class); } /** * @return array */ public function findByDateRange(\DateTimeInterface $start, \DateTimeInterface $end): array { /** @var array $result */ $result = $this->createQueryBuilder('e') ->andWhere('e.from >= :start AND e.from <= :end') ->orWhere('e.to >= :start AND e.to <= :end') ->orWhere('e.from <= :start AND e.to >= :end') ->setParameter('start', $start) ->setParameter('end', $end) ->orderBy('e.from', 'ASC') ->getQuery() ->getResult(); return $result; } }