File tree 2 files changed +9
-2
lines changed
src/Symfony/Component/Serializer
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 18
18
*
19
19
* @Annotation
20
20
* @NamedArgumentConstructor
21
- * @Target({"PROPERTY", "METHOD"})
21
+ * @Target({"PROPERTY", "METHOD", "CLASS" })
22
22
*
23
23
* @author Kévin Dunglas <dunglas@gmail.com>
24
24
*/
25
- #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY )]
25
+ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute:: TARGET_CLASS )]
26
26
class Groups
27
27
{
28
28
/**
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
55
55
$ reflectionClass = $ classMetadata ->getReflectionClass ();
56
56
$ className = $ reflectionClass ->name ;
57
57
$ loaded = false ;
58
+ $ classGroups = [];
58
59
59
60
$ attributesMetadata = $ classMetadata ->getAttributesMetadata ();
60
61
@@ -64,6 +65,8 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
64
65
$ annotation ->getTypeProperty (),
65
66
$ annotation ->getMapping ()
66
67
));
68
+ } elseif ($ annotation instanceof Groups) {
69
+ $ classGroups = $ annotation ->getGroups ();
67
70
}
68
71
}
69
72
@@ -74,6 +77,10 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
74
77
}
75
78
76
79
if ($ property ->getDeclaringClass ()->name === $ className ) {
80
+ foreach ($ classGroups as $ group ) {
81
+ $ attributesMetadata [$ property ->name ]->addGroup ($ group );
82
+ }
83
+
77
84
foreach ($ this ->loadAnnotations ($ property ) as $ annotation ) {
78
85
if ($ annotation instanceof Groups) {
79
86
foreach ($ annotation ->getGroups () as $ group ) {
You can’t perform that action at this time.
0 commit comments