From 893c38fba40211f6c702994d63511ea3c7343bb3 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Fri, 14 May 2021 08:20:23 +0200 Subject: [PATCH] Fix collateral things. --- .../Controller/PersonDuplicateController.php | 10 +++++----- .../Search/SimilarPersonMatcher.php | 15 ++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 48654134d..d30ddebae 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -75,7 +75,7 @@ class PersonDuplicateController extends Controller "You are not allowed to see this person."); $duplicatePersons = $this->similarPersonMatcher-> - matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL); + matchPerson($person, $personNotDuplicateRepository, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL); $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person); @@ -97,7 +97,7 @@ class PersonDuplicateController extends Controller $person1->counters = $this->_getCounters($person1_id); $person2->counters = $this->_getCounters($person2_id); - + if ($person1 === null) { throw $this->createNotFoundException("Person with id $person1_id not" . " found on this server"); @@ -264,17 +264,17 @@ class PersonDuplicateController extends Controller return [$person1, $person2]; } - + private function _getCounters($id): ?array { $em = $this->getDoctrine()->getManager(); - + $nb_activity = $em->getRepository(Activity::class)->findBy(['person'=>$id]); $nb_document = $em->getRepository(PersonDocument::class)->findBy(['person'=>$id]); $nb_event = $em->getRepository(Participation::class)->findBy(['person'=>$id]); $nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person'=>$id]); $person = $em->getRepository(Person::class)->findOneBy(['id'=>$id]); - + return [ 'nb_activity' => count($nb_activity), 'nb_document' => count($nb_document), diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php index c220e62e8..1c564aa11 100644 --- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php +++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php @@ -22,12 +22,13 @@ use Chill\PersonBundle\Entity\PersonNotDuplicate; use Doctrine\ORM\EntityManagerInterface; use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\PersonBundle\Repository\PersonNotDuplicateRepository; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Role\Role; use Chill\PersonBundle\Security\Authorization\PersonVoter; /** - * + * * * @author Julien Fastré */ @@ -41,20 +42,20 @@ class SimilarPersonMatcher * @var EntityManagerInterface */ protected $em; - + /** * @var AuthorizationHelper */ protected $authorizationHelper; - + /** - * @var TokenStorageInterface + * @var TokenStorageInterface */ protected $tokenStorage; - + public function __construct( - EntityManagerInterface $em, - AuthorizationHelper $authorizationHelper, + EntityManagerInterface $em, + AuthorizationHelper $authorizationHelper, TokenStorageInterface $tokenStorage ) { $this->em = $em;