fix service dependency injection for validatorInterface

This commit is contained in:
2021-03-30 11:13:36 +02:00
parent 6ea45e4d16
commit 3a50aea138
7 changed files with 81 additions and 22 deletions

View File

@@ -38,6 +38,7 @@ use Symfony\Component\Translation\TranslatorInterface;
use Chill\MainBundle\Search\SearchProvider;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Class PersonController
@@ -80,6 +81,11 @@ class PersonController extends AbstractController
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var ValidatorInterface
*/
private $validator;
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
@@ -87,7 +93,8 @@ class PersonController extends AbstractController
EventDispatcherInterface $eventDispatcher,
PersonRepository $personRepository,
ConfigPersonAltNamesHelper $configPersonAltNameHelper,
LoggerInterface $logger
LoggerInterface $logger,
ValidatorInterface $validator
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
@@ -95,6 +102,7 @@ class PersonController extends AbstractController
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
$this->personRepository = $personRepository;
$this->logger = $logger;
$this->validator = $validator;
}
public function getCFGroup()
@@ -267,14 +275,14 @@ class PersonController extends AbstractController
*/
private function _validatePersonAndAccompanyingPeriod(Person $person)
{
$errors = $this->get('validator')
$errors = $this->validator
->validate($person, null, array('creation'));
//validate accompanying periods
$periods = $person->getAccompanyingPeriods();
foreach ($periods as $period) {
$period_errors = $this->get('validator')
$period_errors = $this->validator
->validate($period);
//group errors :