mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
paginator added + phpcsfixes
This commit is contained in:
@@ -42,6 +42,33 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
}
|
||||
|
||||
public function buildQueryByUser(?User $user)
|
||||
{
|
||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||
|
||||
$qb->where($qb->expr()->eq('ap.user', ':user'))
|
||||
->andWhere(
|
||||
$qb->expr()->eq('ap.step', ':confirmed'),
|
||||
$qb->expr()->eq('ap.confidential', 'false')
|
||||
)
|
||||
->setParameter('user', $user)
|
||||
->setParameter('confirmed', AccompanyingPeriod::STEP_CONFIRMED);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function countByUserConfirmed(?User $user)
|
||||
{
|
||||
if (null === $user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->buildQueryByUser($user)
|
||||
->select('COUNT(ap)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function findByPerson(
|
||||
Person $person,
|
||||
string $role,
|
||||
@@ -103,16 +130,8 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
return [];
|
||||
}
|
||||
|
||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||
|
||||
$qb->where($qb->expr()->eq('ap.user', ':user'))
|
||||
->andWhere(
|
||||
$qb->expr()->eq('ap.step', ':confirmed')
|
||||
)
|
||||
->setParameter('user', $user)
|
||||
->setParameter('confirmed', AccompanyingPeriod::STEP_CONFIRMED);
|
||||
$qb = $this->buildQueryByUser($user);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user