mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
add possibility to generate filter/order elements, with only search box
for now
This commit is contained in:
@@ -22,11 +22,12 @@ final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepository
|
||||
|
||||
public function listThirdParties(
|
||||
string $role,
|
||||
?string $filterString,
|
||||
?array $orderBy = [],
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
): array {
|
||||
$qb = $this->buildQuery($role);
|
||||
$qb = $this->buildQuery($filterString);
|
||||
|
||||
foreach ($orderBy as $sort => $direction) {
|
||||
$qb->addOrderBy('tp.'.$sort, $direction);
|
||||
@@ -39,15 +40,24 @@ final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepository
|
||||
}
|
||||
|
||||
public function countThirdParties(
|
||||
string $role
|
||||
string $role,
|
||||
?string $filterString
|
||||
): int {
|
||||
$qb = $this->buildQuery($role);
|
||||
$qb = $this->buildQuery($filterString);
|
||||
$qb->select('count(tp)');
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function buildQuery(): QueryBuilder {
|
||||
return $this->thirdPartyRepository->createQueryBuilder('tp');
|
||||
public function buildQuery(?string $filterString = null): QueryBuilder
|
||||
{
|
||||
$qb = $this->thirdPartyRepository->createQueryBuilder('tp');
|
||||
|
||||
if (NULL !== $filterString) {
|
||||
$qb->andWhere($qb->expr()->like('tp.canonicalized', 'LOWER(UNACCENT(:filterString))'))
|
||||
->setParameter('filterString', '%'.$filterString.'%');
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user