class UniqueEntity extends Constraint
Constraint for the Unique Entity validator.
Constants
DEFAULT_GROUP | The name of the group given to all constraints with no explicit group. |
CLASS_CONSTRAINT | Marks a constraint that can be put onto classes. |
PROPERTY_CONSTRAINT | Marks a constraint that can be put onto properties. |
NOT_UNIQUE_ERROR |
Properties
mixed | $payload | Domain-specific data attached to a constraint. | from Constraint |
array | $groups | The groups that the constraint belongs to | from Constraint |
$message | |||
$service | |||
$em | |||
$repositoryMethod | |||
$fields | |||
$errorPath | |||
$ignoreNull |
Methods
static string | getErrorName(string $errorCode) Returns the name of the given error code. | from Constraint |
__construct(mixed $options = null) Initializes the constraint with options. | from Constraint | |
__set(string $option, mixed $value) Sets the value of a lazily initialized option. | from Constraint | |
mixed | __get(string $option) Returns the value of a lazily initialized option. | from Constraint |
addImplicitGroupName(string $group) Adds the given group if this constraint is in the Default group. | from Constraint | |
string | getDefaultOption() Returns the name of the default option. | |
array | getRequiredOptions() Returns the name of the required options. | |
string | validatedBy() The validator must be defined as a service with this name. | |
string|array | getTargets() Returns whether the constraint can be put onto classes, properties or both. | |
array | __sleep() Optimizes the serialized value to minimize storage space. | from Constraint |
Details
static string getErrorName(string $errorCode)
Returns the name of the given error code.
__construct(mixed $options = null)
Initializes the constraint with options.
You should pass an associative array. The keys should be the names of existing properties in this class. The values should be the value for these properties.
Alternatively you can override the method getDefaultOption() to return the name of an existing property. If no associative array is passed, this property is set instead.
You can force that certain options are set by overriding getRequiredOptions() to return the names of these options. If any option is not set here, an exception is thrown.
__set(string $option, mixed $value)
Sets the value of a lazily initialized option.
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
mixed __get(string $option)
Returns the value of a lazily initialized option.
Corresponding properties are added to the object on first access. Hence this method will be called at most once per constraint instance and option name.
addImplicitGroupName(string $group)
Adds the given group if this constraint is in the Default group.
string getDefaultOption()
Returns the name of the default option.
Override this method to define a default option.
array getRequiredOptions()
Returns the name of the required options.
Override this method if you want to define required options.
string validatedBy()
The validator must be defined as a service with this name.
string|array getTargets()
Returns whether the constraint can be put onto classes, properties or both.
This method should return one or more of the constants Constraint::CLASSCONSTRAINT and Constraint::PROPERTYCONSTRAINT.
array __sleep()
Optimizes the serialized value to minimize storage space.
Please login to continue.