mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
adapta list of tasks for a person
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user