Skip to content

Commit 4f5981d

Browse files
committed
minor #9196 Documented the new behavior of getGroupSequence() method (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #9196). Discussion ---------- Documented the new behavior of getGroupSequence() method This fixes #7166. Commits ------- b97fc0d Documented the new behavior of getGroupSequence() method
2 parents d8fcd1c + b97fc0d commit 4f5981d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

validation/sequence_provider.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,22 @@ method, which should return an array of groups to use::
276276

277277
public function getGroupSequence()
278278
{
279-
$groups = array('User');
280-
281-
if ($this->isPremium()) {
282-
$groups[] = 'Premium';
283-
}
284-
285-
return $groups;
279+
// when returning a simple array, if there's a violation in any group
280+
// the rest of groups are not validated. E.g. if 'User' fails,
281+
// 'Premium' and 'Api' are not validated:
282+
return array('User', 'Premium', 'Api');
283+
284+
// when returning a nested array, all the groups included in each array
285+
// are validated. E.g. if 'User' fails, 'Premium' is also validated
286+
// (and you'll get its violations too) but 'Api' won't be validated:
287+
return array(array('User', 'Premium'), 'Api');
286288
}
287289
}
288290

291+
.. versionadded:: 3.2
292+
The feature to return a nested array to get violations from all groups was
293+
introduced in Symfony 3.2.
294+
289295
At last, you have to notify the Validator component that your ``User`` class
290296
provides a sequence of groups to be validated:
291297

0 commit comments

Comments
 (0)