File tree 2 files changed +12
-1
lines changed
src/Symfony/Component/Validator
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,10 @@ public function mergeConstraints(ClassMetadata $source)
354
354
$ member = clone $ member ;
355
355
356
356
foreach ($ member ->getConstraints () as $ constraint ) {
357
- $ member ->constraintsByGroup [$ this ->getDefaultGroup ()][] = $ constraint ;
357
+ if (in_array ($ constraint ::DEFAULT_GROUP , $ constraint ->groups , true )) {
358
+ $ member ->constraintsByGroup [$ this ->getDefaultGroup ()][] = $ constraint ;
359
+ }
360
+
358
361
$ constraint ->addImplicitGroupName ($ this ->getDefaultGroup ());
359
362
}
360
363
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ public function testMergeConstraintsMergesMemberConstraints()
135
135
{
136
136
$ parent = new ClassMetadata (self ::PARENTCLASS );
137
137
$ parent ->addPropertyConstraint ('firstName ' , new ConstraintA ());
138
+ $ parent ->addPropertyConstraint ('firstName ' , new ConstraintB (array ('groups ' => 'foo ' )));
138
139
139
140
$ this ->metadata ->mergeConstraints ($ parent );
140
141
$ this ->metadata ->addPropertyConstraint ('firstName ' , new ConstraintA ());
@@ -148,9 +149,13 @@ public function testMergeConstraintsMergesMemberConstraints()
148
149
'Default ' ,
149
150
'Entity ' ,
150
151
)));
152
+ $ constraintB = new ConstraintB (array (
153
+ 'groups ' => array ('foo ' ),
154
+ ));
151
155
152
156
$ constraints = array (
153
157
$ constraintA1 ,
158
+ $ constraintB ,
154
159
$ constraintA2 ,
155
160
);
156
161
@@ -166,6 +171,9 @@ public function testMergeConstraintsMergesMemberConstraints()
166
171
$ constraintA1 ,
167
172
$ constraintA2 ,
168
173
),
174
+ 'foo ' => array (
175
+ $ constraintB ,
176
+ ),
169
177
);
170
178
171
179
$ members = $ this ->metadata ->getPropertyMetadata ('firstName ' );
You can’t perform that action at this time.
0 commit comments