You are here

public function ClassMetadata::addGetterConstraint 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::addGetterConstraint()

Adds a constraint to the getter of the given property.

The name of the getter is assumed to be the name of the property with an uppercased first letter and either the prefix "get" or "is".

Parameters

string $property The name of the property:

Constraint $constraint The constraint:

Return value

ClassMetadata This object

1 call to ClassMetadata::addGetterConstraint()
ClassMetadata::addGetterConstraints in vendor/symfony/validator/Mapping/ClassMetadata.php

File

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

Class

ClassMetadata
Default implementation of {@link ClassMetadataInterface}.

Namespace

Symfony\Component\Validator\Mapping

Code

public function addGetterConstraint($property, Constraint $constraint) {
  if (!isset($this->getters[$property])) {
    $this->getters[$property] = new GetterMetadata($this
      ->getClassName(), $property);
    $this
      ->addPropertyMetadata($this->getters[$property]);
  }
  $constraint
    ->addImplicitGroupName($this
    ->getDefaultGroup());
  $this->getters[$property]
    ->addConstraint($constraint);
  return $this;
}