mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Repository;
|
||||
@@ -13,10 +20,13 @@ use Symfony\Component\Security\Core\Security;
|
||||
final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
|
||||
{
|
||||
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
|
||||
private Security $security;
|
||||
|
||||
private AuthorizationHelper $authorizationHelper;
|
||||
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
Security $security,
|
||||
@@ -33,13 +43,16 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
Person $person,
|
||||
string $role,
|
||||
?array $orderBy = [],
|
||||
int $limit = null,
|
||||
int $offset = null
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
): array {
|
||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||
$scopes = $this->authorizationHelper
|
||||
->getReachableCircles($this->security->getUser(), $role,
|
||||
$this->centerResolverDispatcher->resolveCenter($person));
|
||||
->getReachableCircles(
|
||||
$this->security->getUser(),
|
||||
$role,
|
||||
$this->centerResolverDispatcher->resolveCenter($person)
|
||||
);
|
||||
|
||||
if (0 === count($scopes)) {
|
||||
return [];
|
||||
@@ -63,20 +76,18 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
->setParameter('draft', AccompanyingPeriod::STEP_DRAFT)
|
||||
->setParameter('person', $person)
|
||||
->setParameter('user', $this->security->getUser())
|
||||
->setParameter('creator', $this->security->getUser())
|
||||
;
|
||||
->setParameter('creator', $this->security->getUser());
|
||||
// add join condition for scopes
|
||||
$orx = $qb->expr()->orX(
|
||||
$qb->expr()->eq('ap.step', ':draft')
|
||||
);
|
||||
|
||||
foreach ($scopes as $key => $scope) {
|
||||
$orx->add($qb->expr()->isMemberOf(':scope_'.$key, 'ap.scopes'));
|
||||
$qb->setParameter('scope_'.$key, $scope);
|
||||
$orx->add($qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes'));
|
||||
$qb->setParameter('scope_' . $key, $scope);
|
||||
}
|
||||
$qb->andWhere($orx);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user