Fix collateral things.

This commit is contained in:
Pol Dellaiera 2021-05-14 08:20:23 +02:00
parent f867f4985d
commit 893c38fba4
2 changed files with 13 additions and 12 deletions

View File

@ -75,7 +75,7 @@ class PersonDuplicateController extends Controller
"You are not allowed to see this person."); "You are not allowed to see this person.");
$duplicatePersons = $this->similarPersonMatcher-> $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); $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person);
@ -97,7 +97,7 @@ class PersonDuplicateController extends Controller
$person1->counters = $this->_getCounters($person1_id); $person1->counters = $this->_getCounters($person1_id);
$person2->counters = $this->_getCounters($person2_id); $person2->counters = $this->_getCounters($person2_id);
if ($person1 === null) { if ($person1 === null) {
throw $this->createNotFoundException("Person with id $person1_id not" throw $this->createNotFoundException("Person with id $person1_id not"
. " found on this server"); . " found on this server");
@ -264,17 +264,17 @@ class PersonDuplicateController extends Controller
return [$person1, $person2]; return [$person1, $person2];
} }
private function _getCounters($id): ?array private function _getCounters($id): ?array
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$nb_activity = $em->getRepository(Activity::class)->findBy(['person'=>$id]); $nb_activity = $em->getRepository(Activity::class)->findBy(['person'=>$id]);
$nb_document = $em->getRepository(PersonDocument::class)->findBy(['person'=>$id]); $nb_document = $em->getRepository(PersonDocument::class)->findBy(['person'=>$id]);
$nb_event = $em->getRepository(Participation::class)->findBy(['person'=>$id]); $nb_event = $em->getRepository(Participation::class)->findBy(['person'=>$id]);
$nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person'=>$id]); $nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person'=>$id]);
$person = $em->getRepository(Person::class)->findOneBy(['id'=>$id]); $person = $em->getRepository(Person::class)->findOneBy(['id'=>$id]);
return [ return [
'nb_activity' => count($nb_activity), 'nb_activity' => count($nb_activity),
'nb_document' => count($nb_document), 'nb_document' => count($nb_document),

View File

@ -22,12 +22,13 @@ 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 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;
/** /**
* *
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop> * @author Julien Fastré <julien.fastre@champs-libres.coop>
*/ */
@ -41,20 +42,20 @@ class SimilarPersonMatcher
* @var EntityManagerInterface * @var EntityManagerInterface
*/ */
protected $em; protected $em;
/** /**
* @var AuthorizationHelper * @var AuthorizationHelper
*/ */
protected $authorizationHelper; protected $authorizationHelper;
/** /**
* @var TokenStorageInterface * @var TokenStorageInterface
*/ */
protected $tokenStorage; protected $tokenStorage;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage TokenStorageInterface $tokenStorage
) { ) {
$this->em = $em; $this->em = $em;