adapta list of tasks for a person

This commit is contained in:
2021-10-29 16:26:19 +02:00
parent 4017f8db48
commit db15a3d53c
10 changed files with 224 additions and 344 deletions

View File

@@ -5,6 +5,7 @@ namespace Chill\TaskBundle\Repository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\TaskBundle\Entity\SingleTask;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\ORM\EntityManagerInterface;
@@ -78,6 +79,33 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
->getQuery()->getSingleScalarResult();
}
public function findByPerson(
Person $person,
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array {
$qb = $this->buildQueryByPerson($person, $pattern, $flags);
$qb = $this->addACL($qb, $person);
return $this->getResult($qb, $start, $limit, $orderBy);
}
public function countByPerson(
Person $person,
?string $pattern = null,
?array $flags = []
): int {
$qb = $this->buildQueryByPerson($person, $pattern, $flags);
return $this
->addACL($qb, $person)
->select('COUNT(t)')
->getQuery()->getSingleScalarResult();
}
public function buildQueryByCourse(
AccompanyingPeriod $course,
?string $pattern = null,
@@ -91,6 +119,19 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
;
}
public function buildQueryByPerson(
Person $person,
?string $pattern = null,
?array $flags = []
): QueryBuilder
{
$qb = $this->buildBaseQuery($pattern, $flags);
return $qb
->andWhere($qb->expr()->eq('t.person', ':person'))
->setParameter('person', $person);
}
public function buildQueryMyTasks(
?string $pattern = null,
?array $flags = []
@@ -123,7 +164,7 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
return $qb->getQuery()->getResult();
}
public function addACL(
private function addACL(
QueryBuilder $qb,
$entity
): QueryBuilder {