mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
refactor: Upgrade repositories.
This commit is contained in:
@@ -18,16 +18,25 @@
|
||||
|
||||
namespace Chill\PersonBundle\Repository;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
/**
|
||||
* Class PersonRepository
|
||||
*
|
||||
* @package Chill\PersonBundle\Repository
|
||||
*/
|
||||
class PersonRepository extends EntityRepository
|
||||
final class PersonRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Person::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null)
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $phonenumber
|
||||
* @param $centers
|
||||
@@ -44,7 +53,7 @@ class PersonRepository extends EntityRepository
|
||||
$maxResults,
|
||||
array $only = ['mobile', 'phone']
|
||||
) {
|
||||
$qb = $this->createQueryBuilder('p');
|
||||
$qb = $this->repository->createQueryBuilder('p');
|
||||
$qb->select('p');
|
||||
|
||||
$this->addByCenters($qb, $centers);
|
||||
@@ -71,7 +80,7 @@ class PersonRepository extends EntityRepository
|
||||
array $only = ['mobile', 'phone']
|
||||
): int
|
||||
{
|
||||
$qb = $this->createQueryBuilder('p');
|
||||
$qb = $this->repository->createQueryBuilder('p');
|
||||
$qb->select('COUNT(p)');
|
||||
|
||||
$this->addByCenters($qb, $centers);
|
||||
|
Reference in New Issue
Block a user