mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
take parameter form_show_center
into account: not to ask center on person creation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Chill\PersonBundle\Validator\Constraints\Person;
|
||||
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
@@ -10,10 +11,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintValidator
|
||||
{
|
||||
private bool $centerRequired;
|
||||
private CenterResolverDispatcher $centerResolverDispatcher;
|
||||
|
||||
public function __construct(ParameterBagInterface $parameterBag)
|
||||
public function __construct(ParameterBagInterface $parameterBag, CenterResolverDispatcher $centerResolverDispatcher)
|
||||
{
|
||||
$this->centerRequired = $parameterBag->get('chill_person')['validation']['center_required'];
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +32,7 @@ class PersonHasCenterValidator extends \Symfony\Component\Validator\ConstraintVa
|
||||
return;
|
||||
}
|
||||
|
||||
if (NULL === $person->getCenter()) {
|
||||
if (NULL === $this->centerResolverDispatcher->resolveCenter($person)) {
|
||||
$this
|
||||
->context
|
||||
->buildViolation($constraint->message)
|
||||
|
Reference in New Issue
Block a user