1717use ApiPlatform \Metadata \ApiProperty ;
1818use ApiPlatform \Metadata \Property \Factory \PropertyMetadataFactoryInterface ;
1919use ApiPlatform \Symfony \Validator \Metadata \Property \Restriction \PropertySchemaRestrictionMetadataInterface ;
20- use ApiPlatform \Symfony \Validator \ValidationGroupsExtractorTrait ;
21- use Psr \Container \ContainerInterface ;
2220use Symfony \Component \Validator \Constraint ;
2321use Symfony \Component \Validator \Constraints \Bic ;
2422use Symfony \Component \Validator \Constraints \CardScheme ;
2826use Symfony \Component \Validator \Constraints \DateTime ;
2927use Symfony \Component \Validator \Constraints \Email ;
3028use Symfony \Component \Validator \Constraints \File ;
29+ use Symfony \Component \Validator \Constraints \GroupSequence ;
3130use Symfony \Component \Validator \Constraints \Iban ;
3231use Symfony \Component \Validator \Constraints \Image ;
3332use Symfony \Component \Validator \Constraints \Isbn ;
4948 */
5049final class ValidatorPropertyMetadataFactory implements PropertyMetadataFactoryInterface
5150{
52- use ValidationGroupsExtractorTrait {
53- getValidationGroups as extractValidationGroups;
54- }
55-
5651 /**
5752 * @var string[] A list of constraint classes making the entity required
5853 */
@@ -78,13 +73,8 @@ final class ValidatorPropertyMetadataFactory implements PropertyMetadataFactoryI
7873 /**
7974 * @param PropertySchemaRestrictionMetadataInterface[] $restrictionsMetadata
8075 */
81- public function __construct (
82- private readonly ValidatorMetadataFactoryInterface $ validatorMetadataFactory ,
83- private readonly PropertyMetadataFactoryInterface $ decorated ,
84- private readonly iterable $ restrictionsMetadata = [],
85- ?ContainerInterface $ container = null ,
86- ) {
87- $ this ->container = $ container ;
76+ public function __construct (private readonly ValidatorMetadataFactoryInterface $ validatorMetadataFactory , private readonly PropertyMetadataFactoryInterface $ decorated , private readonly iterable $ restrictionsMetadata = [])
77+ {
8878 }
8979
9080 /**
@@ -162,8 +152,14 @@ public function create(string $resourceClass, string $property, array $options =
162152 */
163153 private function getValidationGroups (ValidatorClassMetadataInterface $ classMetadata , array $ options ): array
164154 {
165- if (null !== ($ groups = $ this ->extractValidationGroups ($ options ['validation_groups ' ] ?? null ))) {
166- return $ groups ;
155+ if (isset ($ options ['validation_groups ' ])) {
156+ if ($ options ['validation_groups ' ] instanceof GroupSequence) {
157+ return $ options ['validation_groups ' ]->groups ;
158+ }
159+
160+ if (!\is_callable ($ options ['validation_groups ' ])) {
161+ return $ options ['validation_groups ' ];
162+ }
167163 }
168164
169165 if (!method_exists ($ classMetadata , 'getDefaultGroup ' )) {
0 commit comments