mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
Merge remote-tracking branch 'origin/master' into rector/rules-symfony
This commit is contained in:
@@ -34,6 +34,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
public function buildBaseQuery(
|
||||
?string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = []
|
||||
): QueryBuilder {
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
@@ -59,8 +60,12 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
if ($orXUser->count() > 0) {
|
||||
$qb->andWhere($orXUser);
|
||||
}
|
||||
}
|
||||
|
||||
return $qb;
|
||||
if (null !== $types && count($types) > 0) {
|
||||
$qb->andWhere($qb->expr()->in('t.type', ':types'));
|
||||
|
||||
$qb->setParameter('types', $types);
|
||||
}
|
||||
|
||||
if (null !== $flags && count($flags) > 0) {
|
||||
@@ -185,9 +190,10 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
public function countByAllViewable(
|
||||
?string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = []
|
||||
): int {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags, $users);
|
||||
$qb = $this->buildBaseQuery($pattern, $flags, $types, $users);
|
||||
|
||||
return $this
|
||||
->addACLGlobal($qb)
|
||||
@@ -233,12 +239,13 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
public function findByAllViewable(
|
||||
?string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = [],
|
||||
?int $start = 0,
|
||||
?int $limit = 50,
|
||||
?array $orderBy = []
|
||||
): array {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags, $users);
|
||||
$qb = $this->buildBaseQuery($pattern, $flags, $types, $users);
|
||||
$qb = $this->addACLGlobal($qb);
|
||||
|
||||
return $this->getResult($qb, $start, $limit, $orderBy);
|
||||
|
@@ -19,6 +19,7 @@ interface SingleTaskAclAwareRepositoryInterface
|
||||
public function countByAllViewable(
|
||||
?string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = []
|
||||
): int;
|
||||
|
||||
@@ -39,6 +40,7 @@ interface SingleTaskAclAwareRepositoryInterface
|
||||
public function findByAllViewable(
|
||||
?string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = [],
|
||||
?int $start = 0,
|
||||
?int $limit = 50,
|
||||
|
@@ -306,4 +306,28 @@ class SingleTaskRepository extends EntityRepository
|
||||
->add($qb->expr()->isNull('st.endDate'))
|
||||
->add($qb->expr()->isNull('st.warningInterval'));
|
||||
}
|
||||
|
||||
public function countByDistinctTypes()
|
||||
{
|
||||
$qb = $this->createQueryBuilder('st')
|
||||
->select('COUNT(DISTINCT st.type)');
|
||||
|
||||
$this->buildQuery($qb, []);
|
||||
|
||||
return (int) $qb
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function findAllTaskDistinctTypes()
|
||||
{
|
||||
$qb = $this->createQueryBuilder('st')
|
||||
->select('DISTINCT st.type');
|
||||
|
||||
$this->buildQuery($qb, []);
|
||||
|
||||
return $qb
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user