public function ClassMetadata::addPropertyConstraint

Adds a constraint to the given property.

Parameters

string $property The name of the property:

Constraint $constraint The constraint:

Return value

ClassMetadata This object

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php, line 193

Class

ClassMetadata
Represents all the configured constraints on a given class.

Namespace

Symfony\Component\Validator\Mapping

Code

public function addPropertyConstraint($property, Constraint $constraint) {
  if (!isset($this->properties[$property])) {
    $this->properties[$property] = new PropertyMetadata($this
      ->getClassName(), $property);
    $this
      ->addMemberMetadata($this->properties[$property]);
  }
  $constraint
    ->addImplicitGroupName($this
    ->getDefaultGroup());
  $this->properties[$property]
    ->addConstraint($constraint);
  return $this;
}