paginator added + phpcsfixes

This commit is contained in:
2022-03-17 14:13:21 +01:00
parent 6adb647ccc
commit 72ba2c6bca
4 changed files with 61 additions and 36 deletions

View File

@@ -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();
}
}