mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-14 21:31:23 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -17,22 +17,16 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use function count;
|
||||
use function substr;
|
||||
|
||||
final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepositoryInterface
|
||||
{
|
||||
public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private EntityManagerInterface $em, private Security $security, private AuthorizationHelperInterface $authorizationHelper) {}
|
||||
|
||||
public function buildBaseQuery(
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = []
|
||||
@@ -43,18 +37,18 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
if (null !== $pattern && '' !== $pattern) {
|
||||
$qb->andWhere($qb->expr()->like('LOWER(UNACCENT(t.title))', 'LOWER(UNACCENT(:pattern))'))
|
||||
->setParameter('pattern', '%' . $pattern . '%');
|
||||
->setParameter('pattern', '%'.$pattern.'%');
|
||||
}
|
||||
|
||||
if (null !== $users && count($users) > 0) {
|
||||
if (null !== $users && \count($users) > 0) {
|
||||
$orXUser = $qb->expr()->orX();
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
$orXUser->add(
|
||||
$qb->expr()->eq('t.assignee', ':user_' . $key)
|
||||
$qb->expr()->eq('t.assignee', ':user_'.$key)
|
||||
);
|
||||
|
||||
$qb->setParameter('user_' . $key, $user);
|
||||
$qb->setParameter('user_'.$key, $user);
|
||||
}
|
||||
|
||||
if ($orXUser->count() > 0) {
|
||||
@@ -62,16 +56,16 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $types && count($types) > 0) {
|
||||
if (null !== $types && \count($types) > 0) {
|
||||
$qb->andWhere($qb->expr()->in('t.type', ':types'));
|
||||
|
||||
$qb->setParameter('types', $types);
|
||||
}
|
||||
|
||||
if (null !== $flags && count($flags) > 0) {
|
||||
if (null !== $flags && \count($flags) > 0) {
|
||||
$orXDate = $qb->expr()->orX();
|
||||
$orXState = $qb->expr()->orX();
|
||||
$now = new DateTime();
|
||||
$now = new \DateTime();
|
||||
|
||||
foreach ($flags as $key => $flag) {
|
||||
switch ($flag) {
|
||||
@@ -84,7 +78,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
)
|
||||
);
|
||||
$qb
|
||||
->setParameter('intervalBlank', new DateInterval('P0D'))
|
||||
->setParameter('intervalBlank', new \DateInterval('P0D'))
|
||||
->setParameter('now', $now);
|
||||
|
||||
break;
|
||||
@@ -126,7 +120,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
break;
|
||||
|
||||
case str_starts_with((string) $flag, 'state_'):
|
||||
$state = substr((string) $flag, 6);
|
||||
$state = \substr((string) $flag, 6);
|
||||
$orXState
|
||||
->add(
|
||||
"JSONB_EXISTS_IN_ARRAY(t.currentStates, :state_{$key}) = 'TRUE'"
|
||||
@@ -136,7 +130,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LogicException("this flag is not supported: {$flag}");
|
||||
throw new \LogicException("this flag is not supported: {$flag}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +148,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
public function buildQueryByCourse(
|
||||
AccompanyingPeriod $course,
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = []
|
||||
): QueryBuilder {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags);
|
||||
@@ -166,7 +160,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
public function buildQueryByPerson(
|
||||
Person $person,
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = []
|
||||
): QueryBuilder {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags);
|
||||
@@ -177,7 +171,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
}
|
||||
|
||||
public function buildQueryMyTasks(
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = []
|
||||
): QueryBuilder {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags);
|
||||
@@ -188,7 +182,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
}
|
||||
|
||||
public function countByAllViewable(
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = []
|
||||
@@ -203,7 +197,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
public function countByCourse(
|
||||
AccompanyingPeriod $course,
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = []
|
||||
): int {
|
||||
$qb = $this->buildQueryByCourse($course, $pattern, $flags);
|
||||
@@ -215,7 +209,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
}
|
||||
|
||||
public function countByCurrentUsersTasks(
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = []
|
||||
): int {
|
||||
return $this->buildQueryMyTasks($pattern, $flags)
|
||||
@@ -225,7 +219,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
public function countByPerson(
|
||||
Person $person,
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = []
|
||||
): int {
|
||||
$qb = $this->buildQueryByPerson($person, $pattern, $flags);
|
||||
@@ -237,7 +231,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
}
|
||||
|
||||
public function findByAllViewable(
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $types = [],
|
||||
?array $users = [],
|
||||
@@ -253,7 +247,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
public function findByCourse(
|
||||
AccompanyingPeriod $course,
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = [],
|
||||
?int $start = 0,
|
||||
?int $limit = 50,
|
||||
@@ -266,7 +260,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
}
|
||||
|
||||
public function findByCurrentUsersTasks(
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = [],
|
||||
?int $start = 0,
|
||||
?int $limit = 50,
|
||||
@@ -279,7 +273,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
public function findByPerson(
|
||||
Person $person,
|
||||
?string $pattern = null,
|
||||
string $pattern = null,
|
||||
?array $flags = [],
|
||||
?int $start = 0,
|
||||
?int $limit = 50,
|
||||
@@ -304,7 +298,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
->setMaxResults($limit);
|
||||
|
||||
foreach ($orderBy as $field => $direction) {
|
||||
$qb->addOrderBy('t.' . $field, $direction);
|
||||
$qb->addOrderBy('t.'.$field, $direction);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
@@ -360,14 +354,14 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR
|
||||
|
||||
$and = $qb->expr()->andX(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->eq('center_current_person.center', ':center_' . $k),
|
||||
$qb->expr()->eq('center_current_participation.center', ':center_' . $k)
|
||||
$qb->expr()->eq('center_current_person.center', ':center_'.$k),
|
||||
$qb->expr()->eq('center_current_participation.center', ':center_'.$k)
|
||||
),
|
||||
$qb->expr()->in('t.circle', ':scopes_' . $k)
|
||||
$qb->expr()->in('t.circle', ':scopes_'.$k)
|
||||
);
|
||||
$qb
|
||||
->setParameter('center_' . $k, $center)
|
||||
->setParameter('scopes_' . $k, $allowedScopes);
|
||||
->setParameter('center_'.$k, $center)
|
||||
->setParameter('scopes_'.$k, $allowedScopes);
|
||||
$orX->add($and);
|
||||
|
||||
++$k;
|
||||
|
||||
Reference in New Issue
Block a user