add a filtering of tasks by center

This commit is contained in:
2018-10-18 20:51:49 +02:00
parent 7c113e3478
commit fe5f63457b
6 changed files with 47 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\Role\Role;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\DBAL\Types\Type;
use Chill\MainBundle\Entity\Center;
/**
* SingleTaskRepository
@@ -107,6 +108,14 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
if (\array_key_exists('person', $params) and !empty($params['person'])) {
$qb->andWhere($qb->expr()->eq('st.person', ':person'));
$qb->setParameter('person', $params['person']);
} elseif (\array_key_exists('center', $params)) {
if ($params['center'] instanceof Center) {
$qb->join('st.person', 'person');
$qb->andWhere($qb->expr()->eq('person.center', ':center'));
$qb->setParameter('center', $params['center']);
} else {
throw new \UnexpectedValueException("params 'center' should be an instance of ".Center::class);
}
}
if (\array_key_exists('unassigned', $params) and $params['unassigned'] === true) {
@@ -142,7 +151,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
if (\array_key_exists('is_closed', $params)) {
$qb->andWhere($this->buildIsClosed($qb, !$params['is_closed']));
}
}
protected function addTypeFilter(QueryBuilder $qb, $params)