mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user