From 1975a358370070090f36af2bb1ed93383d9e0379 Mon Sep 17 00:00:00 2001
From: Alejandro Celaya
- * The return value is cast to an integer. - * @since 5.1.0 - */ public function count(): int { return $this->repository->countList( diff --git a/module/Core/src/Repository/ShortUrlRepository.php b/module/Core/src/Repository/ShortUrlRepository.php index 27dac54b..95e50f40 100644 --- a/module/Core/src/Repository/ShortUrlRepository.php +++ b/module/Core/src/Repository/ShortUrlRepository.php @@ -33,15 +33,9 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI ?DateRange $dateRange = null ): array { $qb = $this->createListQueryBuilder($searchTerm, $tags, $dateRange); - $qb->select('DISTINCT s'); - - // Set limit and offset - if ($limit !== null) { - $qb->setMaxResults($limit); - } - if ($offset !== null) { - $qb->setFirstResult($offset); - } + $qb->select('DISTINCT s') + ->setMaxResults($limit) + ->setFirstResult($offset); // In case the ordering has been specified, the query could be more complex. Process it if ($orderBy !== null && $orderBy->hasOrderField()) { @@ -147,7 +141,7 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI WHERE s.shortCode = :shortCode AND (s.domain IS NULL OR d.authority = :domain) ORDER BY s.domain {$ordering} -DQL; + DQL; $query = $this->getEntityManager()->createQuery($dql); $query->setMaxResults(1) @@ -220,9 +214,8 @@ DQL; } if ($meta->hasValidUntil()) { $qb->andWhere($qb->expr()->eq('s.validUntil', ':validUntil')) - ->setParameter('validUntil', $meta->getValidUntil()); + ->setParameter('validUntil', $meta->getValidUntil()); } - if ($meta->hasDomain()) { $qb->join('s.domain', 'd') ->andWhere($qb->expr()->eq('d.authority', ':domain'))