mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +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;
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
|
||||
interface ThirdPartyACLAwareRepositoryInterface
|
||||
{
|
||||
public function countThirdParties(string $role): int;
|
||||
public function countThirdParties(string $role, ?string $filterString): int;
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
@@ -17,8 +17,9 @@ interface ThirdPartyACLAwareRepositoryInterface
|
||||
*/
|
||||
public function listThirdParties(
|
||||
string $role,
|
||||
?string $filterString,
|
||||
?array $orderBy = [],
|
||||
int $limit = null,
|
||||
int $offset = null
|
||||
?int $limit = 0,
|
||||
?int $offset = 50
|
||||
): array;
|
||||
}
|
||||
|
Reference in New Issue
Block a user