cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,16 +1,24 @@
<?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.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Security;
final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepositoryInterface
{
private Security $security;
private AuthorizationHelper $authorizationHelper;
private Security $security;
private ThirdPartyRepository $thirdPartyRepository;
public function __construct(Security $security, AuthorizationHelper $authorizationHelper, ThirdPartyRepository $thirdPartyRepository)
@@ -20,23 +28,16 @@ final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepository
$this->thirdPartyRepository = $thirdPartyRepository;
}
public function listThirdParties(
string $role,
?string $filterString,
?array $orderBy = [],
?int $limit = null,
?int $offset = null
): array {
$qb = $this->buildQuery($filterString);
public function buildQuery(?string $filterString = null): QueryBuilder
{
$qb = $this->thirdPartyRepository->createQueryBuilder('tp');
foreach ($orderBy as $sort => $direction) {
$qb->addOrderBy('tp.'.$sort, $direction);
if (null !== $filterString) {
$qb->andWhere($qb->expr()->like('tp.canonicalized', 'LOWER(UNACCENT(:filterString))'))
->setParameter('filterString', '%' . $filterString . '%');
}
$qb->setFirstResult($offset)
->setMaxResults($limit);
return $qb->getQuery()->getResult();
return $qb;
}
public function countThirdParties(
@@ -49,15 +50,22 @@ final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepository
return $qb->getQuery()->getSingleScalarResult();
}
public function buildQuery(?string $filterString = null): QueryBuilder
{
$qb = $this->thirdPartyRepository->createQueryBuilder('tp');
public function listThirdParties(
string $role,
?string $filterString,
?array $orderBy = [],
?int $limit = null,
?int $offset = null
): array {
$qb = $this->buildQuery($filterString);
if (NULL !== $filterString) {
$qb->andWhere($qb->expr()->like('tp.canonicalized', 'LOWER(UNACCENT(:filterString))'))
->setParameter('filterString', '%'.$filterString.'%');
foreach ($orderBy as $sort => $direction) {
$qb->addOrderBy('tp.' . $sort, $direction);
}
return $qb;
$qb->setFirstResult($offset)
->setMaxResults($limit);
return $qb->getQuery()->getResult();
}
}