Symfony\Component\Validator\Context\ExecutionContext::__construct PHP Метод

__construct() публичный Метод

Creates a new execution context.
public __construct ( Symfony\Component\Validator\Validator\ValidatorInterface $validator, mixed $root, Symfony\Component\Translation\TranslatorInterface $translator, string | null $translationDomain = null )
$validator Symfony\Component\Validator\Validator\ValidatorInterface The validator
$root mixed The root value of the validated object graph
$translator Symfony\Component\Translation\TranslatorInterface The translator
$translationDomain string | null The translation domain to use for translating violation messages
    public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, $translationDomain = null)
    {
        $this->validator = $validator;
        $this->root = $root;
        $this->translator = $translator;
        $this->translationDomain = $translationDomain;
        $this->violations = new ConstraintViolationList();
    }

Usage Example

 /**
  * Creates a new context.
  *
  * @see ExecutionContext::__construct()
  *
  * @internal Called by {@link LegacyExecutionContextFactory}. Should not be used
  *           in user code.
  */
 public function __construct(ValidatorInterface $validator, $root, MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null)
 {
     parent::__construct($validator, $root, $translator, $translationDomain);
     $this->metadataFactory = $metadataFactory;
 }