mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 13:33:48 +00:00
Merge remote-tracking branch 'origin/master' into calendar/synchro-msgraph
This commit is contained in:
@@ -118,10 +118,24 @@ final class UserRepository implements ObjectRepository
|
||||
return $this->entityManager->createNativeQuery($sql, $rsm)->setParameter(':key', $key)->getResult();
|
||||
}
|
||||
|
||||
public function findByUsernameOrEmail(string $pattern)
|
||||
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
$qb = $this->queryByUsernameOrEmail($pattern);
|
||||
|
||||
$qb->select('u');
|
||||
|
||||
if (null !== $limit) {
|
||||
$qb->setMaxResults($limit);
|
||||
}
|
||||
|
||||
if (null !== $offset) {
|
||||
$qb->setFirstResult($offset);
|
||||
}
|
||||
|
||||
foreach ($orderBy as $field => $order) {
|
||||
$qb->addOrderBy('u.' . $field, $order);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
@@ -199,13 +213,13 @@ final class UserRepository implements ObjectRepository
|
||||
|
||||
private function queryByUsernameOrEmail(string $pattern): QueryBuilder
|
||||
{
|
||||
$qb = $this->entityManager->createQueryBuilder('u');
|
||||
$qb = $this->entityManager->createQueryBuilder()->from(User::class, 'u');
|
||||
|
||||
$searchByPattern = $qb->expr()->orX();
|
||||
|
||||
$searchByPattern
|
||||
->add($qb->expr()->eq('u.usernameCanonical', 'LOWER(UNACCENT(:pattern))'))
|
||||
->add($qb->expr()->eq('u.emailCanonical', 'LOWER(UNACCENT(:pattern))'));
|
||||
->add($qb->expr()->like('u.usernameCanonical', 'CONCAT(\'%\', LOWER(UNACCENT(:pattern)), \'%\')'))
|
||||
->add($qb->expr()->like('u.emailCanonical', 'CONCAT(\'%\', LOWER(UNACCENT(:pattern)), \'%\')'));
|
||||
|
||||
$qb
|
||||
->where($searchByPattern)
|
||||
|
Reference in New Issue
Block a user