mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
refactor: Upgrade repositories.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* @method AccompanyingPeriodWorkGoal|null find($id, $lockMode = null, $lockVersion = null)
|
||||
@@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method AccompanyingPeriodWorkGoal[] findAll()
|
||||
* @method AccompanyingPeriodWorkGoal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class AccompanyingPeriodWorkGoalRepository extends ServiceEntityRepository
|
||||
final class AccompanyingPeriodWorkGoalRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
parent::__construct($registry, AccompanyingPeriodWorkGoal::class);
|
||||
$this->repository = $entityManager->getRepository(AccompanyingPeriodWorkGoal::class);
|
||||
}
|
||||
}
|
||||
|
@@ -3,8 +3,8 @@
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* @method AccompanyingPeriodWork|null find($id, $lockMode = null, $lockVersion = null)
|
||||
@@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method AccompanyingPeriodWork[] findAll()
|
||||
* @method AccompanyingPeriodWork[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class AccompanyingPeriodWorkRepository extends ServiceEntityRepository
|
||||
final class AccompanyingPeriodWorkRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
parent::__construct($registry, AccompanyingPeriodWork::class);
|
||||
$this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class);
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -23,8 +23,8 @@
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* @method Comment|null find($id, $lockMode = null, $lockVersion = null)
|
||||
@@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method Comment[] findAll()
|
||||
* @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class CommentRepository extends ServiceEntityRepository
|
||||
final class CommentRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
parent::__construct($registry, Comment::class);
|
||||
$this->repository = $entityManager->getRepository(Comment::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,8 +23,8 @@
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* @method Origin|null find($id, $lockMode = null, $lockVersion = null)
|
||||
@@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method Origin[] findAll()
|
||||
* @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class OriginRepository extends ServiceEntityRepository
|
||||
final class OriginRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Origin::class);
|
||||
}
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Origin::class);
|
||||
}
|
||||
}
|
||||
|
@@ -23,8 +23,8 @@
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* @method Resource|null find($id, $lockMode = null, $lockVersion = null)
|
||||
@@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method Resource[] findAll()
|
||||
* @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ResourceRepository extends ServiceEntityRepository
|
||||
final class ResourceRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Resource::class);
|
||||
}
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Resource::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user