Merge branch 'master' into _8_entity_parcours

This commit is contained in:
2021-03-30 11:21:06 +02:00
77 changed files with 8081 additions and 20 deletions

View File

@@ -34,6 +34,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Class AccompanyingPeriodController
@@ -48,13 +49,20 @@ class AccompanyingPeriodController extends AbstractController
protected $eventDispatcher;
/**
* ReportController constructor.
* @var ValidatorInterface
*/
protected $validator;
/**
* AccompanyingPeriodController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
* @param ValidatorInterface $validator
*/
public function __construct(EventDispatcherInterface $eventDispatcher)
public function __construct(EventDispatcherInterface $eventDispatcher, ValidatorInterface $validator)
{
$this->eventDispatcher = $eventDispatcher;
$this->validator = $validator;
}
public function listAction(int $person_id): Response
@@ -282,9 +290,10 @@ class AccompanyingPeriodController extends AbstractController
private function _validatePerson(Person $person): ConstraintViolationListInterface
{
$errors = $this->get('validator')->validate($person, null,
$errors = $this->validator->validate($person, null,
['Default']);
$errors_accompanying_period = $this->get('validator')->validate($person, null,
$errors_accompanying_period = $this->validator->validate($person, null,
['accompanying_period_consistent']);
foreach($errors_accompanying_period as $error ) {

View File

@@ -29,6 +29,7 @@ use Chill\MainBundle\Form\Type\AddressType;
use Chill\MainBundle\Entity\Address;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Class PersonAddressController
@@ -40,7 +41,21 @@ use Symfony\Component\HttpFoundation\Request;
*/
class PersonAddressController extends AbstractController
{
/**
* @var ValidatorInterface
*/
protected $validator;
/**
* PersonAddressController constructor.
*
* @param ValidatorInterface $validator
*/
public function __construct(ValidatorInterface $validator)
{
$this->validator = $validator;
}
public function listAction($person_id)
{
$person = $this->getDoctrine()->getManager()
@@ -302,9 +317,9 @@ class PersonAddressController extends AbstractController
*/
private function validatePerson(Person $person)
{
$errors = $this->get('validator')
$errors = $this->validator
->validate($person, null, array('Default'));
$errors_addresses_consistent = $this->get('validator')
$errors_addresses_consistent = $this->validator
->validate($person, null, array('addresses_consistent'));
foreach($errors_addresses_consistent as $error) {

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 :