mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -35,9 +35,6 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface
|
||||
{
|
||||
public function __construct(
|
||||
@@ -75,7 +72,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array
|
||||
{
|
||||
$qb = $this->buildBaseQuery($filters);
|
||||
@@ -83,7 +79,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
$qb->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $period);
|
||||
|
||||
foreach ($orderBy as $field => $order) {
|
||||
$qb->addOrderBy('a.' . $field, $order);
|
||||
$qb->addOrderBy('a.'.$field, $order);
|
||||
}
|
||||
|
||||
if (null !== $start) {
|
||||
@@ -124,25 +120,25 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
"SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy "
|
||||
. "AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate "
|
||||
. "AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)",
|
||||
'SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy '
|
||||
.'AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate '
|
||||
.'AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)',
|
||||
User\UserJobHistory::class
|
||||
)
|
||||
),
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
"SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user "
|
||||
. "AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate "
|
||||
. "AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)",
|
||||
'SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user '
|
||||
.'AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate '
|
||||
.'AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)',
|
||||
User\UserJobHistory::class
|
||||
)
|
||||
),
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
"SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users "
|
||||
. "AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate "
|
||||
. "AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)",
|
||||
'SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users '
|
||||
.'AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate '
|
||||
.'AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)',
|
||||
User\UserJobHistory::class
|
||||
)
|
||||
),
|
||||
@@ -163,7 +159,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod|Person $associated
|
||||
* @return array<ActivityType>
|
||||
*/
|
||||
public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array
|
||||
@@ -225,7 +220,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function findByAccompanyingPeriodSimplified(AccompanyingPeriod $period, ?int $limit = 1000): array
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->em);
|
||||
@@ -313,7 +307,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
$qb = $this->filterBaseQueryByPerson($qb, $person, $role);
|
||||
|
||||
foreach ($orderBy as $field => $direction) {
|
||||
$qb->addOrderBy('a.' . $field, $direction);
|
||||
$qb->addOrderBy('a.'.$field, $direction);
|
||||
}
|
||||
|
||||
if (null !== $start) {
|
||||
@@ -340,7 +334,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
$orX->add(sprintf('a.person = :person AND a.scope IN (:scopes_%d)', $counter));
|
||||
$qb->setParameter(sprintf('scopes_%d', $counter), $scopes);
|
||||
$qb->setParameter('person', $person);
|
||||
$counter++;
|
||||
++$counter;
|
||||
}
|
||||
|
||||
foreach ($person->getAccompanyingPeriodParticipations() as $participation) {
|
||||
@@ -363,7 +357,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
->setParameter(sprintf('participation_end_%d', $counter), $participation->getEndDate());
|
||||
}
|
||||
$orX->add($and);
|
||||
$counter++;
|
||||
++$counter;
|
||||
}
|
||||
|
||||
if (0 === $orX->count()) {
|
||||
@@ -384,10 +378,10 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
|
||||
return [
|
||||
'id' => $metadataActivity->getTableName()
|
||||
. '.' . $metadataActivity->getColumnName('id'),
|
||||
.'.'.$metadataActivity->getColumnName('id'),
|
||||
'type' => 'activity',
|
||||
'date' => $metadataActivity->getTableName()
|
||||
. '.' . $metadataActivity->getColumnName('date'),
|
||||
.'.'.$metadataActivity->getColumnName('date'),
|
||||
'FROM' => $from,
|
||||
'WHERE' => $where,
|
||||
'parameters' => $parameters,
|
||||
@@ -400,12 +394,12 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||
|
||||
return $metadataActivity->getTableName() . ' JOIN '
|
||||
. $metadataPerson->getTableName() . ' ON '
|
||||
. $metadataPerson->getTableName() . '.' .
|
||||
return $metadataActivity->getTableName().' JOIN '
|
||||
.$metadataPerson->getTableName().' ON '
|
||||
.$metadataPerson->getTableName().'.'.
|
||||
$associationMapping['joinColumns'][0]['referencedColumnName']
|
||||
. ' = '
|
||||
. $associationMapping['joinColumns'][0]['name'];
|
||||
.' = '
|
||||
.$associationMapping['joinColumns'][0]['name'];
|
||||
}
|
||||
|
||||
private function getWhereClause(string $context, array $args): array
|
||||
@@ -424,7 +418,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
ActivityVoter::SEE
|
||||
);
|
||||
|
||||
if (count($reachableCenters) === 0) {
|
||||
if (0 === \count($reachableCenters)) {
|
||||
// insert a dummy condition
|
||||
return 'FALSE = TRUE';
|
||||
}
|
||||
@@ -441,7 +435,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
// we pass if not in centers
|
||||
if (!in_array($center, $args['centers'], true)) {
|
||||
if (!\in_array($center, $args['centers'], true)) {
|
||||
continue;
|
||||
}
|
||||
// we get all the reachable scopes for this center
|
||||
@@ -463,7 +457,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
|
||||
// begin loop for scopes
|
||||
$where .= ' AND (';
|
||||
$scopesI = 0; //like scope#i
|
||||
$scopesI = 0; // like scope#i
|
||||
|
||||
foreach ($reachablesScopesId as $scopeId) {
|
||||
if (0 < $scopesI) {
|
||||
|
Reference in New Issue
Block a user