Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ClassMetadata.php

function ClassMetadata::mergeConstraints

Merges the constraints of the given metadata into this object.

File

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

Class

ClassMetadata
Default implementation of {@link ClassMetadataInterface}.

Namespace

Symfony\Component\Validator\Mapping

Code

public function mergeConstraints(self $source) : void {
    if ($source->isGroupSequenceProvider()) {
        $this->setGroupProvider($source->getGroupProvider());
        $this->setGroupSequenceProvider(true);
    }
    foreach ($source->getConstraints() as $constraint) {
        $this->addConstraint(clone $constraint);
    }
    foreach ($source->getConstrainedProperties() as $property) {
        foreach ($source->getPropertyMetadata($property) as $member) {
            $member = clone $member;
            foreach ($member->getConstraints() as $constraint) {
                if (\in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
                    $member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
                }
                $constraint->addImplicitGroupName($this->getDefaultGroup());
            }
            if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
                $property = $member->getPropertyName();
                $this->members[$property][] = $member;
                if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
                    $this->properties[$property] = $member;
                }
                elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
                    $this->getters[$property] = $member;
                }
            }
            else {
                $this->addPropertyMetadata($member);
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal