ConstraintValidatorFactory deprecated

ConstraintValidatorFactory deprecated

class ConstraintValidatorFactory extends ContainerConstraintValidatorFactory

deprecated

since version 3.3

Uses a service container to create constraint validators.

A constraint validator should be tagged as "validator.constraint_validator" in the service container and include an "alias" attribute:

<service id="some_doctrine_validator">
    <argument type="service" id="doctrine.orm.some_entity_manager" />
    <tag name="validator.constraint_validator" alias="some_alias" />
</service>

A constraint may then return this alias in its validatedBy() method:

public function validatedBy()
{
    return 'some_alias';
}

Methods

__construct(ContainerInterface $container, array $validators = array())
ConstraintValidatorInterface getInstance(Constraint $constraint)

Returns the validator for the supplied constraint.

Details

__construct(ContainerInterface $container, array $validators = array())

Parameters

ContainerInterface $container
array $validators

ConstraintValidatorInterface getInstance(Constraint $constraint)

Returns the validator for the supplied constraint.

Parameters

Constraint $constraint The source constraint

Return Value

ConstraintValidatorInterface

Exceptions

ValidatorException When the validator class does not exist
UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部