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\LoaderCode
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);
}
}