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

Breadcrumb

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

function PropertyInfoLoader::handleAllConstraintLegacy

BC layer for PropertyTypeExtractorInterface::getTypes(). Can be removed as soon as PropertyTypeExtractorInterface::getTypes() is removed (8.0).

1 call to PropertyInfoLoader::handleAllConstraintLegacy()
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 297

Class

PropertyInfoLoader
Guesses and loads the appropriate constraints using PropertyInfo.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

private function handleAllConstraintLegacy(string $property, ?All $allConstraint, PropertyInfoType $propertyInfoType, 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 && !$propertyInfoType->isNullable()) {
        $constraints[] = new NotNull();
    }
    if (!$containsTypeConstraint) {
        $constraints[] = $this->getTypeConstraintLegacy($propertyInfoType->getBuiltinType(), $propertyInfoType);
    }
    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