Violation\LegacyConstraintViolationBuilder (Component\Validator)

Symfony\Component\Validator\Violation\LegacyConstraintViolationBuilder

class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInterface

Backwards-compatible implementation of {@link ConstraintViolationBuilderInterface}.

Methods

__construct(ExecutionContextInterface $context, $message, array $parameters)
ConstraintViolationBuilderInterface atPath(string $path)

Stores the property path at which the violation should be generated.

ConstraintViolationBuilderInterface setParameter(string $key, string $value)

Sets a parameter to be inserted into the violation message.

ConstraintViolationBuilderInterface setParameters(array $parameters)

Sets all parameters to be inserted into the violation message.

ConstraintViolationBuilderInterface setTranslationDomain(string $translationDomain)

Sets the translation domain which should be used for translating the violation message.

ConstraintViolationBuilderInterface setInvalidValue(mixed $invalidValue)

Sets the invalid value that caused this violation.

ConstraintViolationBuilderInterface setPlural(int $number)

Sets the number which determines how the plural form of the violation message is chosen when it is translated.

ConstraintViolationBuilderInterface setCode(string|null $code)

Sets the violation code.

ConstraintViolationBuilderInterface setCause(mixed $cause)

Sets the cause of the violation.

addViolation()

Adds the violation to the current execution context.

Details

public __construct(ExecutionContextInterface $context, $message, array $parameters)

Parameters

ExecutionContextInterface $context
$message
array $parameters

public ConstraintViolationBuilderInterface atPath(string $path)

Stores the property path at which the violation should be generated.

The passed path will be appended to the current property path of the execution context.

Parameters

string $path The property path

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setParameter(string $key, string $value)

Sets a parameter to be inserted into the violation message.

Parameters

string $key The name of the parameter
string $value The value to be inserted in the parameter's place

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setParameters(array $parameters)

Sets all parameters to be inserted into the violation message.

Parameters

array $parameters An array with the parameter names as keys and the values to be inserted in their place as values

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setTranslationDomain(string $translationDomain)

Sets the translation domain which should be used for translating the violation message.

Parameters

string $translationDomain The translation domain

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setInvalidValue(mixed $invalidValue)

Sets the invalid value that caused this violation.

Parameters

mixed $invalidValue The invalid value

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setPlural(int $number)

Sets the number which determines how the plural form of the violation message is chosen when it is translated.

Parameters

int $number The number for determining the plural form

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setCode(string|null $code)

Sets the violation code.

Parameters

string|null $code The violation code

Return Value

ConstraintViolationBuilderInterface This builder

public ConstraintViolationBuilderInterface setCause(mixed $cause)

Sets the cause of the violation.

Parameters

mixed $cause The cause of the violation

Return Value

ConstraintViolationBuilderInterface This builder

public addViolation()

Adds the violation to the current execution context.

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部