17
17
use ApiPlatform \Metadata \ApiProperty ;
18
18
use ApiPlatform \Metadata \Property \Factory \PropertyMetadataFactoryInterface ;
19
19
use ApiPlatform \Symfony \Validator \Metadata \Property \Restriction \PropertySchemaRestrictionMetadataInterface ;
20
- use ApiPlatform \Symfony \Validator \ValidationGroupsExtractorTrait ;
21
- use Psr \Container \ContainerInterface ;
22
20
use Symfony \Component \Validator \Constraint ;
23
21
use Symfony \Component \Validator \Constraints \Bic ;
24
22
use Symfony \Component \Validator \Constraints \CardScheme ;
28
26
use Symfony \Component \Validator \Constraints \DateTime ;
29
27
use Symfony \Component \Validator \Constraints \Email ;
30
28
use Symfony \Component \Validator \Constraints \File ;
29
+ use Symfony \Component \Validator \Constraints \GroupSequence ;
31
30
use Symfony \Component \Validator \Constraints \Iban ;
32
31
use Symfony \Component \Validator \Constraints \Image ;
33
32
use Symfony \Component \Validator \Constraints \Isbn ;
49
48
*/
50
49
final class ValidatorPropertyMetadataFactory implements PropertyMetadataFactoryInterface
51
50
{
52
- use ValidationGroupsExtractorTrait {
53
- getValidationGroups as extractValidationGroups;
54
- }
55
-
56
51
/**
57
52
* @var string[] A list of constraint classes making the entity required
58
53
*/
@@ -78,13 +73,8 @@ final class ValidatorPropertyMetadataFactory implements PropertyMetadataFactoryI
78
73
/**
79
74
* @param PropertySchemaRestrictionMetadataInterface[] $restrictionsMetadata
80
75
*/
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
+ {
88
78
}
89
79
90
80
/**
@@ -162,8 +152,14 @@ public function create(string $resourceClass, string $property, array $options =
162
152
*/
163
153
private function getValidationGroups (ValidatorClassMetadataInterface $ classMetadata , array $ options ): array
164
154
{
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
+ }
167
163
}
168
164
169
165
if (!method_exists ($ classMetadata , 'getDefaultGroup ' )) {
0 commit comments