|
@@ -33,27 +33,27 @@ class FilmRepository extends ServiceEntityRepository
|
|
|
return $query->getSingleResult();
|
|
|
}
|
|
|
|
|
|
- public function findFilmWithGenre(array $genreNames, array $filters = []) : Paginator
|
|
|
+ public function findFilmWithGenre(array $genreNames, array $filters = [], int $page) : QueryBuilder
|
|
|
{
|
|
|
- $qb = $this->queryFilter($filters);
|
|
|
+ $qb = $this->queryFilter($filters, $page);
|
|
|
$qb
|
|
|
->innerJoin('f.genres', 'g')
|
|
|
->addSelect('f');
|
|
|
|
|
|
$qb->where($qb->expr()->in('g.name', $genreNames));
|
|
|
|
|
|
- return new Paginator($qb->getQuery());
|
|
|
+ return $qb;
|
|
|
}
|
|
|
|
|
|
- public function findFilmWithReal(array $realisateursnames, array $filters = []): Paginator
|
|
|
+ public function findFilmWithReal(array $realisateursnames, array $filters = [], int $page): QueryBuilder
|
|
|
{
|
|
|
- $qb = $this->queryFilter($filters);
|
|
|
+ $qb = $this->queryFilter($filters, $page);
|
|
|
$qb
|
|
|
->leftJoin('f.realisateurs', 'rea')
|
|
|
->addSelect('f')
|
|
|
->where($qb->expr()->in('rea.nomComplet', $realisateursnames));
|
|
|
|
|
|
- return new Paginator($qb->getQuery());
|
|
|
+ return $qb;
|
|
|
}
|
|
|
|
|
|
public function findFilmWithRealLike($query): array
|
|
@@ -85,12 +85,17 @@ class FilmRepository extends ServiceEntityRepository
|
|
|
->getResult();
|
|
|
}
|
|
|
|
|
|
- public function queryFilter(array $filters = []): QueryBuilder
|
|
|
+ public function queryFilter(array $filters = [], int $page = 1): QueryBuilder
|
|
|
{
|
|
|
$qb = $this->createQueryBuilder('f')
|
|
|
- ->orderBy('f.'.($filters['sortBy'] ?? 'dateSubmited'), $filters['sortOrder'] ?? 'DESC')
|
|
|
- ->setMaxResults((int)($filters['limit'] ?? 100))
|
|
|
- ;
|
|
|
+ ->orderBy('f.'.($filters['sortBy'] ?? 'dateSubmited'), $filters['sortOrder'] ?? 'DESC');
|
|
|
+
|
|
|
+ if ($filters['limit']) {
|
|
|
+ $limit = (int)$filters['limit'];
|
|
|
+ $qb->setFirstResult(($page * $limit) - $limit);
|
|
|
+ $qb->setMaxResults($limit);
|
|
|
+ }
|
|
|
+
|
|
|
if ($filters['note']) {
|
|
|
$qb
|
|
|
->andWhere('f.note >= :note')
|
|
@@ -108,19 +113,19 @@ class FilmRepository extends ServiceEntityRepository
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function findTous (array $filters = []): Paginator
|
|
|
+ public function queryTous (array $filters = [], int $page): QueryBuilder
|
|
|
{
|
|
|
- $qb = $this->queryFilter($filters)
|
|
|
+ $qb = $this->queryFilter($filters, $page)
|
|
|
->leftJoin('f.authered', 'aut')->addSelect('aut')
|
|
|
->leftJoin('f.genres', 'gen')->addSelect('gen')
|
|
|
->leftJoin('f.realisateurs', 'rea')->addSelect('rea')
|
|
|
;
|
|
|
- return new Paginator($qb->getQuery());
|
|
|
+ return $qb;
|
|
|
}
|
|
|
|
|
|
- public function findTousFavoritesByUser($user, array $filters = []): Paginator
|
|
|
+ public function queryTousFavoritesByUser($user, array $filters = [], int $page): QueryBuilder
|
|
|
{
|
|
|
- $qb = $this->queryFilter($filters);
|
|
|
+ $qb = $this->queryFilter($filters, $page);
|
|
|
$qb
|
|
|
->leftJoin('f.authered', 'aut')->addSelect('aut')
|
|
|
->leftJoin('f.genres', 'gen')->addSelect('gen')
|
|
@@ -129,7 +134,7 @@ class FilmRepository extends ServiceEntityRepository
|
|
|
->where($qb->expr()->in('wan', ':user'))
|
|
|
->setParameter('user', $user)
|
|
|
;
|
|
|
- return new Paginator($qb->getQuery());
|
|
|
+ return $qb;
|
|
|
}
|
|
|
|
|
|
public function findProchaines(): array
|