/** * @param string $property * @param Assert $constraint * @param string $group */ public function addPropertyConstraint($property, Assert $constraint, $group = null) { $propertyMetadata = $this->getPropertyMetadata($property); if ($propertyMetadata === null) { $propertyMetadata = new PropertyMetadata($this->getClassName(), $property); $propertyMetadata->defaultGroup = $this->defaultGroup; } $propertyMetadata->addConstraint($constraint, $group); $this->addPropertyMetadata($propertyMetadata); }
/** * Merges the constraints of the given metadata into this object. * * @param PropertyMetadata $source */ public function mergeConstraints(PropertyMetadata $source) { foreach ($source->getConstraints() as $group => $constraints) { $this->addConstraints($constraints, $group); } }