mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 20:43:49 +00:00
refactor: Upgrade repositories.
This commit is contained in:
@@ -22,8 +22,9 @@
|
||||
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
|
||||
/**
|
||||
@@ -32,17 +33,24 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
*
|
||||
* @package Chill\PersonBundle\Repository
|
||||
*/
|
||||
class ClosingMotiveRepository extends EntityRepository
|
||||
final class ClosingMotiveRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(ClosingMotive::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $onlyLeaf
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActiveClosingMotive(bool $onlyLeaf = true)
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->getEntityManager());
|
||||
$rsm->addRootEntityFromClassMetadata($this->getClassName(), 'cm');
|
||||
|
||||
$rsm = new ResultSetMappingBuilder($this->repository->getEntityManager());
|
||||
$rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm');
|
||||
|
||||
$sql = "SELECT ".(string) $rsm."
|
||||
FROM chill_person_accompanying_period_closingmotive AS cm
|
||||
WHERE
|
||||
@@ -55,10 +63,11 @@ class ClosingMotiveRepository extends EntityRepository
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY cm.ordering ASC";
|
||||
|
||||
return $this->_em
|
||||
|
||||
return $this
|
||||
->repository
|
||||
->getEntityManager()
|
||||
->createNativeQuery($sql, $rsm)
|
||||
->getResult()
|
||||
;
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user