person: move similar person matcher to PersonACLEwareRepository

This commit is contained in:
nobohan
2022-02-17 11:33:06 +01:00
parent aebb21935b
commit a3ffd2709d
3 changed files with 99 additions and 12 deletions

View File

@@ -16,8 +16,8 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Form\CreationPersonType;
use Chill\PersonBundle\Form\PersonType;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
@@ -56,11 +56,6 @@ final class PersonController extends AbstractController
*/
protected $personRepository;
/**
* @var SimilarPersonMatcher
*/
protected $similarPersonMatcher;
/**
* @var TranslatorInterface
*/
@@ -81,8 +76,9 @@ final class PersonController extends AbstractController
*/
private $validator;
private PersonACLAwareRepositoryInterface $personACLAwareRepository;
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
PersonRepository $personRepository,
@@ -90,9 +86,9 @@ final class PersonController extends AbstractController
LoggerInterface $logger,
ValidatorInterface $validator,
EntityManagerInterface $em,
Security $security
Security $security,
PersonACLAwareRepositoryInterface $personACLAwareRepository
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
@@ -101,6 +97,7 @@ final class PersonController extends AbstractController
$this->validator = $validator;
$this->em = $em;
$this->security = $security;
$this->personACLAwareRepository = $personACLAwareRepository;
}
public function editAction($person_id, Request $request)
@@ -236,8 +233,8 @@ final class PersonController extends AbstractController
$request->getMethod() === Request::METHOD_POST
&& $form->isValid()
) {
$alternatePersons = $this->similarPersonMatcher
->matchPerson($person);
$alternatePersons = $this->personACLAwareRepository
->findMatchingPersons($person);
if (
false === $this->isLastPostDataChanges($form, $request, true)