You are here

public function ClassMetadata::addPropertyConstraint in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Mapping/ClassMetadata.php \Symfony\Component\Validator\Mapping\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

1 call to ClassMetadata::addPropertyConstraint()
ClassMetadata::addPropertyConstraints in vendor/symfony/validator/Mapping/ClassMetadata.php

File

vendor/symfony/validator/Mapping/ClassMetadata.php, line 266

Class

ClassMetadata
Default implementation of {@link ClassMetadataInterface}.

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
      ->addPropertyMetadata($this->properties[$property]);
  }
  $constraint
    ->addImplicitGroupName($this
    ->getDefaultGroup());
  $this->properties[$property]
    ->addConstraint($constraint);
  return $this;
}