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

Breadcrumb

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

function PropertyInfoLoader::handleAllConstraint

1 call to PropertyInfoLoader::handleAllConstraint()
PropertyInfoLoader::loadClassMetadata in vendor/symfony/validator/Mapping/Loader/PropertyInfoLoader.php
Loads validation metadata into a {@link ClassMetadata} instance.

File

vendor/symfony/validator/Mapping/Loader/PropertyInfoLoader.php, line 259

Class

PropertyInfoLoader
Guesses and loads the appropriate constraints using PropertyInfo.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

private function handleAllConstraint(string $property, ?All $allConstraint, TypeInfoType $type, ClassMetadata $metadata) : void {
    $containsTypeConstraint = false;
    $containsNotNullConstraint = false;
    if (null !== $allConstraint) {
        foreach ($allConstraint->constraints as $constraint) {
            if ($constraint instanceof Type) {
                $containsTypeConstraint = true;
            }
            elseif ($constraint instanceof NotNull) {
                $containsNotNullConstraint = true;
            }
        }
    }
    $constraints = [];
    if (!$containsNotNullConstraint && !$type->isNullable()) {
        $constraints[] = new NotNull();
    }
    if (!$containsTypeConstraint && null !== ($typeConstraint = $this->getTypeConstraint($type))) {
        $constraints[] = $typeConstraint;
    }
    if (!$constraints) {
        return;
    }
    if (null === $allConstraint) {
        $metadata->addPropertyConstraint($property, new All([
            'constraints' => $constraints,
        ]));
    }
    else {
        $allConstraint->constraints = array_merge($allConstraint->constraints, $constraints);
    }
}

API Navigation

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