centerRequired = $parameterBag->get('chill_person')['validation']['center_required']; $this->centerResolverDispatcher = $centerResolverDispatcher; } /** * @inheritDoc */ public function validate($person, Constraint $constraint) { if (!$person instanceof Person) { throw new UnexpectedTypeException($constraint, Person::class); } if (!$this->centerRequired) { return; } if (NULL === $this->centerResolverDispatcher->resolveCenter($person)) { $this ->context ->buildViolation($constraint->message) ->atPath('center') ->addViolation() ; } } }