refactor: Upgrade repositories.

This commit is contained in:
Pol Dellaiera 2021-05-06 11:43:14 +02:00
parent 55695b7d2c
commit 174d873398
40 changed files with 324 additions and 292 deletions

View File

@ -37,3 +37,7 @@ services:
- "%chill_person.validation.birtdate_not_before%" - "%chill_person.validation.birtdate_not_before%"
tags: tags:
- { name: validator.constraint_validator, alias: birthdate_not_before } - { name: validator.constraint_validator, alias: birthdate_not_before }
Chill\PersonBundle\Repository\:
resource: '../src/Repository/'
tags: ['doctrine.repository_service']

View File

@ -2,24 +2,6 @@ services:
chill.person.repository.person: chill.person.repository.person:
class: Chill\PersonBundle\Repository\PersonRepository class: Chill\PersonBundle\Repository\PersonRepository
factory: ['@doctrine.orm.entity_manager', getRepository] autowire: true
arguments: autoconfigure: true
- 'Chill\PersonBundle\Entity\Person'
Chill\PersonBundle\Repository\PersonRepository: '@chill.person.repository.person' Chill\PersonBundle\Repository\PersonRepository: '@chill.person.repository.person'
Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository:
class: Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository
factory: ['@doctrine.orm.entity_manager', getRepository]
arguments:
- 'Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive'
Chill\PersonBundle\Repository\AccompanyingPeriodRepository:
class: Chill\PersonBundle\Repository\AccompanyingPeriodRepository
tags: [ doctrine.repository_service ]
arguments:
- '@Doctrine\Persistence\ManagerRegistry'
Chill\PersonBundle\Repository\AccompanyingPeriodParticipationRepository:
arguments:
- '@Doctrine\Persistence\ManagerRegistry'
tags: [ doctrine.repository_service ]

View File

@ -38,6 +38,7 @@ use Symfony\Component\Translation\TranslatorInterface;
use Chill\MainBundle\Search\SearchProvider; use Chill\MainBundle\Search\SearchProvider;
use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -290,7 +291,7 @@ final class PersonController extends AbstractController
return $errors; return $errors;
} }
public function reviewAction(Request $request) public function reviewAction(Request $request, PersonNotDuplicateRepository $personNotDuplicateRepository)
{ {
if ($request->getMethod() !== 'POST') { if ($request->getMethod() !== 'POST') {
$r = new Response("You must send something to review the creation of a new Person"); $r = new Response("You must send something to review the creation of a new Person");
@ -342,8 +343,7 @@ final class PersonController extends AbstractController
$this->em->persist($person); $this->em->persist($person);
$alternatePersons = $this->similarPersonMatcher $alternatePersons = $this->similarPersonMatcher->matchPerson($person, $personNotDuplicateRepository);
->matchPerson($person);
if (count($alternatePersons) === 0) { if (count($alternatePersons) === 0) {
return $this->forward('ChillPersonBundle:Person:create'); return $this->forward('ChillPersonBundle:Person:create');

View File

@ -19,6 +19,7 @@ use Symfony\Component\Translation\TranslatorInterface;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Entity\Participation;
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
use Chill\TaskBundle\Entity\SingleTask; use Chill\TaskBundle\Entity\SingleTask;
class PersonDuplicateController extends Controller class PersonDuplicateController extends Controller
@ -62,7 +63,7 @@ class PersonDuplicateController extends Controller
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
} }
public function viewAction($person_id) public function viewAction($person_id, PersonNotDuplicateRepository $personNotDuplicateRepository)
{ {
$person = $this->_getPerson($person_id); $person = $this->_getPerson($person_id);
if ($person === null) { if ($person === null) {
@ -76,8 +77,7 @@ class PersonDuplicateController extends Controller
$duplicatePersons = $this->similarPersonMatcher-> $duplicatePersons = $this->similarPersonMatcher->
matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL); matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL);
$notDuplicatePersons = $this->getDoctrine()->getRepository(PersonNotDuplicate::class) $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person);
->findNotDuplicatePerson($person);
return $this->render('ChillPersonBundle:PersonDuplicate:view.html.twig', [ return $this->render('ChillPersonBundle:PersonDuplicate:view.html.twig', [
'person' => $person, 'person' => $person,

View File

@ -37,7 +37,7 @@ use Chill\MainBundle\Entity\User;
/** /**
* AccompanyingPeriod Class * AccompanyingPeriod Class
* *
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\AccompanyingPeriodRepository") * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period") * @ORM\Table(name="chill_person_accompanying_period")
*/ */
class AccompanyingPeriod class AccompanyingPeriod

View File

@ -4,7 +4,6 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
@ -13,7 +12,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=AccompanyingPeriodWorkRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_work") * @ORM\Table(name="chill_person_accompanying_period_work")
*/ */
class AccompanyingPeriodWork class AccompanyingPeriodWork

View File

@ -4,13 +4,12 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkGoalRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=AccompanyingPeriodWorkGoalRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_work_goal") * @ORM\Table(name="chill_person_accompanying_period_work_goal")
*/ */
class AccompanyingPeriodWorkGoal class AccompanyingPeriodWorkGoal

View File

@ -29,8 +29,7 @@ use Doctrine\Common\Collections\ArrayCollection;
/** /**
* ClosingMotive give an explanation why we closed the Accompanying period * ClosingMotive give an explanation why we closed the Accompanying period
* *
* @ORM\Entity( * @ORM\Entity
* repositoryClass="Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository")
* @ORM\Table(name="chill_person_accompanying_period_closingmotive") * @ORM\Table(name="chill_person_accompanying_period_closingmotive")
*/ */
class ClosingMotive class ClosingMotive

View File

@ -22,13 +22,12 @@
namespace Chill\PersonBundle\Entity\AccompanyingPeriod; namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriod\CommentRepository;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=CommentRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_comment") * @ORM\Table(name="chill_person_accompanying_period_comment")
*/ */
class Comment class Comment

View File

@ -22,11 +22,10 @@
namespace Chill\PersonBundle\Entity\AccompanyingPeriod; namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\OriginRepository;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=OriginRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_origin") * @ORM\Table(name="chill_person_accompanying_period_origin")
*/ */
class Origin class Origin

View File

@ -22,7 +22,6 @@
namespace Chill\PersonBundle\Entity\AccompanyingPeriod; namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriod\ResourceRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
@ -30,7 +29,7 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=ResourceRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_resource") * @ORM\Table(name="chill_person_accompanying_period_resource")
*/ */
class Resource class Resource

View File

@ -22,7 +22,6 @@
namespace Chill\PersonBundle\Entity; namespace Chill\PersonBundle\Entity;
use Chill\PersonBundle\Repository\AccompanyingPeriodParticipationRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -31,7 +30,7 @@ use Doctrine\ORM\Mapping as ORM;
* AccompanyingPeriodParticipation Class * AccompanyingPeriodParticipation Class
* *
* @package Chill\PersonBundle\Entity * @package Chill\PersonBundle\Entity
* @ORM\Entity(repositoryClass=AccompanyingPeriodParticipationRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_participation") * @ORM\Table(name="chill_person_accompanying_period_participation")
*/ */
class AccompanyingPeriodParticipation class AccompanyingPeriodParticipation

View File

@ -25,7 +25,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* MaritalStatus * MaritalStatus
* *
* @ORM\Entity() * @ORM\Entity
* @ORM\Table(name="chill_person_marital_status") * @ORM\Table(name="chill_person_marital_status")
* @ORM\HasLifecycleCallbacks() * @ORM\HasLifecycleCallbacks()
*/ */

View File

@ -38,7 +38,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
/** /**
* Person Class * Person Class
* *
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\PersonRepository") * @ORM\Entity
* @ORM\Table(name="chill_person_person", * @ORM\Table(name="chill_person_person",
* indexes={@ORM\Index( * indexes={@ORM\Index(
* name="person_names", * name="person_names",

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
* PersonAltName * PersonAltName
* *
* @ORM\Table(name="chill_person_alt_name") * @ORM\Table(name="chill_person_alt_name")
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\PersonAltNameRepository") * @ORM\Entity
*/ */
class PersonAltName class PersonAltName
{ {

View File

@ -9,7 +9,7 @@ use Chill\MainBundle\Entity\User;
* PersonNotDuplicate * PersonNotDuplicate
* *
* @ORM\Table(name="chill_person_not_duplicate") * @ORM\Table(name="chill_person_not_duplicate")
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\PersonNotDuplicateRepository") * @ORM\Entity
*/ */
class PersonNotDuplicate class PersonNotDuplicate
{ {

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Person Phones * Person Phones
* *
* @ORM\Entity() * @ORM\Entity
* @ORM\Table(name="chill_person_phone") * @ORM\Table(name="chill_person_phone")
*/ */
class PersonPhone class PersonPhone

View File

@ -2,11 +2,10 @@
namespace Chill\PersonBundle\Entity\SocialWork; namespace Chill\PersonBundle\Entity\SocialWork;
use Chill\PersonBundle\Repository\SocialWork\EvaluationRepository;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=EvaluationRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_social_work_evaluation") * @ORM\Table(name="chill_person_social_work_evaluation")
*/ */
class Evaluation class Evaluation

View File

@ -2,13 +2,12 @@
namespace Chill\PersonBundle\Entity\SocialWork; namespace Chill\PersonBundle\Entity\SocialWork;
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=GoalRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_social_work_goal") * @ORM\Table(name="chill_person_social_work_goal")
*/ */
class Goal class Goal

View File

@ -4,13 +4,12 @@ namespace Chill\PersonBundle\Entity\SocialWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=ResultRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_social_work_result") * @ORM\Table(name="chill_person_social_work_result")
*/ */
class Result class Result

View File

@ -2,13 +2,12 @@
namespace Chill\PersonBundle\Entity\SocialWork; namespace Chill\PersonBundle\Entity\SocialWork;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=SocialActionRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_social_action") * @ORM\Table(name="chill_person_social_action")
*/ */
class SocialAction class SocialAction

View File

@ -1,14 +1,12 @@
<?php <?php
namespace Chill\PersonBundle\Entity\SocialWork; namespace Chill\PersonBundle\Entity\SocialWork;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* @ORM\Entity(repositoryClass=SocialIssueRepository::class) * @ORM\Entity
* @ORM\Table(name="chill_person_social_issue") * @ORM\Table(name="chill_person_social_issue")
*/ */
class SocialIssue class SocialIssue

View File

@ -3,8 +3,8 @@
namespace Chill\PersonBundle\Repository\AccompanyingPeriod; namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method AccompanyingPeriodWorkGoal|null find($id, $lockMode = null, $lockVersion = null) * @method AccompanyingPeriodWorkGoal|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method AccompanyingPeriodWorkGoal[] findAll() * @method AccompanyingPeriodWorkGoal[] findAll()
* @method AccompanyingPeriodWorkGoal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method AccompanyingPeriodWorkGoal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class AccompanyingPeriodWorkGoalRepository extends ServiceEntityRepository 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);
} }
} }

View File

@ -3,8 +3,8 @@
namespace Chill\PersonBundle\Repository\AccompanyingPeriod; namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method AccompanyingPeriodWork|null find($id, $lockMode = null, $lockVersion = null) * @method AccompanyingPeriodWork|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method AccompanyingPeriodWork[] findAll() * @method AccompanyingPeriodWork[] findAll()
* @method AccompanyingPeriodWork[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method AccompanyingPeriodWork[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class AccompanyingPeriodWorkRepository extends ServiceEntityRepository 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);
} }
} }

View File

@ -22,6 +22,8 @@
namespace Chill\PersonBundle\Repository\AccompanyingPeriod; namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\Query\ResultSetMappingBuilder;
@ -32,16 +34,23 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder;
* *
* @package Chill\PersonBundle\Repository * @package Chill\PersonBundle\Repository
*/ */
class ClosingMotiveRepository extends EntityRepository class ClosingMotiveRepository
{ {
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(ClosingMotive::class);
}
/** /**
* @param bool $onlyLeaf * @param bool $onlyLeaf
* @return mixed * @return mixed
*/ */
public function getActiveClosingMotive(bool $onlyLeaf = true) public function getActiveClosingMotive(bool $onlyLeaf = true)
{ {
$rsm = new ResultSetMappingBuilder($this->getEntityManager()); $rsm = new ResultSetMappingBuilder($this->repository->getEntityManager());
$rsm->addRootEntityFromClassMetadata($this->getClassName(), 'cm'); $rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm');
$sql = "SELECT ".(string) $rsm." $sql = "SELECT ".(string) $rsm."
FROM chill_person_accompanying_period_closingmotive AS cm FROM chill_person_accompanying_period_closingmotive AS cm
@ -56,9 +65,10 @@ class ClosingMotiveRepository extends EntityRepository
$sql .= " ORDER BY cm.ordering ASC"; $sql .= " ORDER BY cm.ordering ASC";
return $this->_em return $this
->repository
->getEntityManager()
->createNativeQuery($sql, $rsm) ->createNativeQuery($sql, $rsm)
->getResult() ->getResult();
;
} }
} }

View File

@ -23,8 +23,8 @@
namespace Chill\PersonBundle\Repository\AccompanyingPeriod; namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method Comment|null find($id, $lockMode = null, $lockVersion = null) * @method Comment|null find($id, $lockMode = null, $lockVersion = null)
@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Comment[] findAll() * @method Comment[] findAll()
* @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class CommentRepository extends ServiceEntityRepository class CommentRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
{
parent::__construct($registry, Comment::class);
}
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(Comment::class);
}
} }

View File

@ -23,8 +23,8 @@
namespace Chill\PersonBundle\Repository\AccompanyingPeriod; namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method Origin|null find($id, $lockMode = null, $lockVersion = null) * @method Origin|null find($id, $lockMode = null, $lockVersion = null)
@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Origin[] findAll() * @method Origin[] findAll()
* @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class OriginRepository extends ServiceEntityRepository class OriginRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
{
parent::__construct($registry, Origin::class);
}
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(Origin::class);
}
} }

View File

@ -23,8 +23,8 @@
namespace Chill\PersonBundle\Repository\AccompanyingPeriod; namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource; use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method Resource|null find($id, $lockMode = null, $lockVersion = null) * @method Resource|null find($id, $lockMode = null, $lockVersion = null)
@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Resource[] findAll() * @method Resource[] findAll()
* @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class ResourceRepository extends ServiceEntityRepository class ResourceRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
{
parent::__construct($registry, Resource::class);
}
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(Resource::class);
}
} }

View File

@ -23,8 +23,8 @@
namespace Chill\PersonBundle\Repository; namespace Chill\PersonBundle\Repository;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null) * @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null)
@ -32,11 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method AccompanyingPeriodParticipation[] findAll() * @method AccompanyingPeriodParticipation[] findAll()
* @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class AccompanyingPeriodParticipationRepository extends ServiceEntityRepository class AccompanyingPeriodParticipationRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
{
parent::__construct($registry, AccompanyingPeriodParticipation::class);
}
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(AccompanyingPeriodParticipation::class);
}
} }

View File

@ -23,9 +23,8 @@
namespace Chill\PersonBundle\Repository; namespace Chill\PersonBundle\Repository;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/** /**
* @method AccompanyingPeriod|null find($id, $lockMode = null, $lockVersion = null) * @method AccompanyingPeriod|null find($id, $lockMode = null, $lockVersion = null)
@ -33,10 +32,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method AccompanyingPeriod[] findAll() * @method AccompanyingPeriod[] findAll()
* @method AccompanyingPeriod[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method AccompanyingPeriod[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class AccompanyingPeriodRepository extends ServiceEntityRepository class AccompanyingPeriodRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, AccompanyingPeriod::class); $this->repository = $entityManager->getRepository(AccompanyingPeriod::class);
} }
} }

View File

@ -2,12 +2,22 @@
namespace Chill\PersonBundle\Repository; namespace Chill\PersonBundle\Repository;
use Chill\PersonBundle\Entity\PersonAltName;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
/** /**
* PersonAltNameRepository * PersonAltNameRepository
* *
* This class was generated by the Doctrine ORM. Add your own custom * This class was generated by the Doctrine ORM. Add your own custom
* repository methods below. * repository methods below.
*/ */
class PersonAltNameRepository extends \Doctrine\ORM\EntityRepository class PersonAltNameRepository
{ {
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(PersonAltName::class);
}
} }

View File

@ -4,6 +4,7 @@ namespace Chill\PersonBundle\Repository;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonNotDuplicate; use Chill\PersonBundle\Entity\PersonNotDuplicate;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
/** /**
@ -11,8 +12,15 @@ use Doctrine\ORM\EntityRepository;
* *
* @package Chill\PersonBundle\Repository * @package Chill\PersonBundle\Repository
*/ */
class PersonNotDuplicateRepository extends EntityRepository class PersonNotDuplicateRepository
{ {
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(PersonNotDuplicate::class);
}
/** /**
* @param \Chill\PersonBundle\Entity\Person $person * @param \Chill\PersonBundle\Entity\Person $person
* *
@ -20,7 +28,7 @@ class PersonNotDuplicateRepository extends EntityRepository
*/ */
public function findNotDuplicatePerson(Person $person) public function findNotDuplicatePerson(Person $person)
{ {
$qb = $this->createQueryBuilder('pnd'); $qb = $this->repository->createQueryBuilder('pnd');
$qb->select('pnd') $qb->select('pnd')
->where('pnd.person1 = :person OR pnd.person2 = :person') ->where('pnd.person1 = :person OR pnd.person2 = :person')
; ;

View File

@ -18,16 +18,25 @@
namespace Chill\PersonBundle\Repository; namespace Chill\PersonBundle\Repository;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
/** final class PersonRepository
* Class PersonRepository
*
* @package Chill\PersonBundle\Repository
*/
class PersonRepository extends EntityRepository
{ {
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 string $phonenumber
* @param $centers * @param $centers
@ -44,7 +53,7 @@ class PersonRepository extends EntityRepository
$maxResults, $maxResults,
array $only = ['mobile', 'phone'] array $only = ['mobile', 'phone']
) { ) {
$qb = $this->createQueryBuilder('p'); $qb = $this->repository->createQueryBuilder('p');
$qb->select('p'); $qb->select('p');
$this->addByCenters($qb, $centers); $this->addByCenters($qb, $centers);
@ -71,7 +80,7 @@ class PersonRepository extends EntityRepository
array $only = ['mobile', 'phone'] array $only = ['mobile', 'phone']
): int ): int
{ {
$qb = $this->createQueryBuilder('p'); $qb = $this->repository->createQueryBuilder('p');
$qb->select('COUNT(p)'); $qb->select('COUNT(p)');
$this->addByCenters($qb, $centers); $this->addByCenters($qb, $centers);

View File

@ -3,8 +3,8 @@
namespace Chill\PersonBundle\Repository\SocialWork; namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method Evaluation|null find($id, $lockMode = null, $lockVersion = null) * @method Evaluation|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Evaluation[] findAll() * @method Evaluation[] findAll()
* @method Evaluation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Evaluation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class EvaluationRepository extends ServiceEntityRepository class EvaluationRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, Evaluation::class); $this->repository = $entityManager->getRepository(Evaluation::class);
} }
} }

View File

@ -3,8 +3,8 @@
namespace Chill\PersonBundle\Repository\SocialWork; namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Goal;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method Goal|null find($id, $lockMode = null, $lockVersion = null) * @method Goal|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Goal[] findAll() * @method Goal[] findAll()
* @method Goal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Goal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class GoalRepository extends ServiceEntityRepository class GoalRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, Goal::class); $this->repository = $entityManager->getRepository(Goal::class);
} }
} }

View File

@ -3,8 +3,8 @@
namespace Chill\PersonBundle\Repository\SocialWork; namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\Result;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method Result|null find($id, $lockMode = null, $lockVersion = null) * @method Result|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Result[] findAll() * @method Result[] findAll()
* @method Result[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Result[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class ResultRepository extends ServiceEntityRepository class ResultRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, Result::class); $this->repository = $entityManager->getRepository(Result::class);
} }
} }

View File

@ -3,8 +3,8 @@
namespace Chill\PersonBundle\Repository\SocialWork; namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityRepository;
/** /**
* @method SocialAction|null find($id, $lockMode = null, $lockVersion = null) * @method SocialAction|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +12,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method SocialAction[] findAll() * @method SocialAction[] findAll()
* @method SocialAction[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method SocialAction[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class SocialActionRepository extends ServiceEntityRepository class SocialActionRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, SocialAction::class); $this->repository = $entityManager->getRepository(SocialAction::class);
} }
} }

View File

@ -4,7 +4,8 @@ namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
/** /**
* @method SocialIssue|null find($id, $lockMode = null, $lockVersion = null) * @method SocialIssue|null find($id, $lockMode = null, $lockVersion = null)
@ -12,10 +13,12 @@ use Doctrine\Persistence\ManagerRegistry;
* @method SocialIssue[] findAll() * @method SocialIssue[] findAll()
* @method SocialIssue[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method SocialIssue[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class SocialIssueRepository extends ServiceEntityRepository class SocialIssueRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, SocialIssue::class); $this->repository = $entityManager->getRepository(SocialIssue::class);
} }
} }

View File

@ -22,6 +22,8 @@ use Chill\PersonBundle\Entity\PersonNotDuplicate;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
use Chill\PersonBundle\Repository\PersonRepository;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
@ -62,7 +64,7 @@ class SimilarPersonMatcher
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
} }
public function matchPerson(Person $person, $precision = 0.15, $orderBy = self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY) public function matchPerson(Person $person, PersonNotDuplicateRepository $personNotDuplicateRepository, $precision = 0.15, $orderBy = self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY)
{ {
$centers = $this->authorizationHelper->getReachableCenters( $centers = $this->authorizationHelper->getReachableCenters(
$this->tokenStorage->getToken()->getUser(), $this->tokenStorage->getToken()->getUser(),
@ -77,8 +79,7 @@ class SimilarPersonMatcher
. ' AND p.id != :personId ' . ' AND p.id != :personId '
; ;
$notDuplicatePersons = $this->em->getRepository(PersonNotDuplicate::class) $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person);
->findNotDuplicatePerson($person);
if (count($notDuplicatePersons)) { if (count($notDuplicatePersons)) {
$dql .= ' AND p.id not in (:notDuplicatePersons)'; $dql .= ' AND p.id not in (:notDuplicatePersons)';

View File

@ -30,6 +30,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\PersonBundle\Repository\PersonRepository;
use Twig\Environment; use Twig\Environment;
/** /**
@ -45,7 +46,7 @@ class PersonListWidget implements WidgetInterface
/** /**
* Repository for persons * Repository for persons
* *
* @var EntityRepository * @var PersonRepository
*/ */
protected $personRepository; protected $personRepository;
@ -76,7 +77,7 @@ class PersonListWidget implements WidgetInterface
protected $user; protected $user;
public function __construct( public function __construct(
EntityRepository $personRepostory, PersonRepository $personRepostory,
EntityManager $em, EntityManager $em,
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
TokenStorage $tokenStorage TokenStorage $tokenStorage