Class

Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity

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

Properties

array $groups
$message
$em
$fields

Methods

__construct(mixed $options = null)

Initializes the constraint with options.

from Constraint
__set($option, $value)

Unsupported operation.

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

Details

in Constraint at line 85
public __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.

Parameters

mixed $options The options (as associative array) or the value for the default option (any other type)

Exceptions

InvalidOptionsException When you pass the names of non-existing options
MissingOptionsException When you don't pass any of the options returned by getRequiredOptions()
ConstraintDefinitionException When you don't pass an associative array, but getDefaultOption() returns NULL

in Constraint at line 140
public __set($option, $value)

Unsupported operation.

Parameters

$option
$value

in Constraint at line 152
public addImplicitGroupName(string $group)

Adds the given group if this constraint is in the Default group

Parameters

string $group

at line 51
public string getDefaultOption()

Returns the name of the default option

Override this method to define a default option.

Return Value

string

at line 28
public array getRequiredOptions()

Returns the name of the required options

Override this method if you want to define required options.

Return Value

array

at line 38
public string validatedBy()

The validator must be defined as a service with this name.

Return Value

string

at line 46
public 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.

Return Value

string|array One or more constant values