#111688Allow dependency injection in validators of Symfony constraints
Description
ConstraintDecoratingValidator builds a new Symfony validator on every call with Validation::createValidatorBuilder() and without the service container. Constraint validators are therefore created with new:
- A constraint validator of an extension cannot have constructor dependencies (a repository, a site finder, a service).
- Symfony’s
Expressionconstraint cannot be used, as its validator needs the expression language service. - The validator and its metadata are built again for each validated property.
Goal: Extbase provides one Symfony validator as a service that resolves constraint validators through the container (ContainerConstraintValidatorFactory). A class extending ConstraintValidator in an extension is a service and gets its dependencies by constructor injection. ConstraintDecoratingValidator uses this service.
Reviews 1
History 02
-
Gerrit Code Review pushed patch set 1 for main to change 98214 status
NewUnder Review 11/30/26, 13:04 -
Gerrit Code Review pushed patch set 2 for main to change 98214 11/30/26, 13:15