mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
@@ -47,13 +46,13 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): int
|
||||
public function countNearEndDateByUser(User $user, \DateTimeImmutable $since, \DateTimeImmutable $until): int
|
||||
{
|
||||
return $this->buildQueryNearEndDateByUser($user, $since, $until)
|
||||
->select('count(w)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
@@ -68,7 +67,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -91,8 +90,9 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
* * first, opened works
|
||||
* * then, closed works
|
||||
*
|
||||
* @param array{types?: list<SocialAction>, user?: list<User>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||
*
|
||||
* @return AccompanyingPeriodWork[]
|
||||
* @param array{types?: list<SocialAction>, user?: list<User>, after?: null|\DateTimeImmutable, before?: null|\DateTimeImmutable} $filters
|
||||
*/
|
||||
public function findByAccompanyingPeriodOpenFirst(AccompanyingPeriod $period, array $filters, int $limit = 10, int $offset = 0): array
|
||||
{
|
||||
@@ -106,23 +106,23 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
// implement filters
|
||||
|
||||
if ([] !== ($filters['types'] ?? [])) {
|
||||
$sql .= " AND w.socialaction_id IN (:types)";
|
||||
$sql .= ' AND w.socialaction_id IN (:types)';
|
||||
}
|
||||
|
||||
if ([] !== ($filters['user'] ?? [])) {
|
||||
$sql .= " AND rw.user_id IN ("
|
||||
. implode(
|
||||
$sql .= ' AND rw.user_id IN ('
|
||||
.implode(
|
||||
', ',
|
||||
// we add a user_xx for each key of the 'user' list
|
||||
array_map(fn (User $u, int $idx) => ':user_' . $idx, $filters['user'], array_keys($filters['user']))
|
||||
array_map(fn (User $u, int $idx) => ':user_'.$idx, $filters['user'], array_keys($filters['user']))
|
||||
)
|
||||
. ")";
|
||||
.')';
|
||||
}
|
||||
|
||||
$sql .= " AND daterange(:after::date, :before::date) && daterange(w.startDate, w.endDate, '[]')";
|
||||
|
||||
// if the start and end date were inversed, we inverse the order to avoid an error
|
||||
if (null !== ($filters['after'] ?? null) && null !== ($filters['before']) && $filters['after'] > $filters['before']) {
|
||||
if (null !== ($filters['after'] ?? null) && null !== $filters['before'] && $filters['after'] > $filters['before']) {
|
||||
$before = $filters['after'];
|
||||
$after = $filters['before'];
|
||||
} else {
|
||||
@@ -137,7 +137,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
w.enddate DESC,
|
||||
w.id DESC";
|
||||
|
||||
$sql .= " LIMIT :limit OFFSET :offset";
|
||||
$sql .= ' LIMIT :limit OFFSET :offset';
|
||||
|
||||
$typeIds = [];
|
||||
foreach ($filters['types'] as $type) {
|
||||
@@ -153,14 +153,14 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
->setParameter('offset', $offset, Types::INTEGER);
|
||||
|
||||
foreach ($filters['user'] as $key => $user) {
|
||||
$nq->setParameter('user_' . $key, $user);
|
||||
$nq->setParameter('user_'.$key, $user);
|
||||
}
|
||||
|
||||
return $nq->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of types of social actions associated to the accompanying period
|
||||
* Return a list of types of social actions associated to the accompanying period.
|
||||
*
|
||||
* @return array<SocialAction>
|
||||
*/
|
||||
@@ -171,10 +171,8 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
->select('1')
|
||||
->from(AccompanyingPeriodWork::class, 'apw');
|
||||
|
||||
|
||||
$in->andWhere('apw.accompanyingPeriod = :period')->setParameter('period', $period);
|
||||
|
||||
|
||||
// join between the embedded exist query and the main query
|
||||
$in->andWhere('apw.socialAction = sa');
|
||||
|
||||
@@ -189,7 +187,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until, int $limit = 20, int $offset = 0): array
|
||||
public function findNearEndDateByUser(User $user, \DateTimeImmutable $since, \DateTimeImmutable $until, int $limit = 20, int $offset = 0): array
|
||||
{
|
||||
return $this->buildQueryNearEndDateByUser($user, $since, $until)
|
||||
->select('w')
|
||||
@@ -227,7 +225,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
return $qb;
|
||||
}
|
||||
|
||||
private function buildQueryNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): QueryBuilder
|
||||
private function buildQueryNearEndDateByUser(User $user, \DateTimeImmutable $since, \DateTimeImmutable $until): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('w');
|
||||
|
||||
@@ -240,7 +238,7 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->eq('period.user', ':user'),
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . AccompanyingPeriodWork::class . ' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = w.id AND subw_ref_history.user = :user and subw.ref_history.endDate IS NULL'
|
||||
'SELECT 1 FROM '.AccompanyingPeriodWork::class.' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = w.id AND subw_ref_history.user = :user and subw.ref_history.endDate IS NULL'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user