@@ -344,8 +344,8 @@ provides a sequence of groups to be validated:
344
344
}
345
345
}
346
346
347
- Advanced Group Sequence Provider
348
- --------------------------------
347
+ Advanced Validation Group Provider
348
+ ----------------------------------
349
349
350
350
In the previous section, you learned how to dynamically determine the
351
351
sequence of groups to apply based on the state of your entity. This
@@ -359,21 +359,21 @@ be cumbersome, and the implementation might not align with the entity
359
359
responsibilities.
360
360
361
361
To address this, you can now configure the implementation of the
362
- :class: `Symfony\\ Component\\ Validator\\ GroupSequenceProviderInterface `
363
- outside of the entity, and even register the group sequence provider as a
362
+ :class: `Symfony\\ Component\\ Validator\\ GroupProviderInterface `
363
+ outside of the entity, and even register the group provider as a
364
364
service if necessary.
365
365
366
366
Here's how you can achieve this:
367
367
368
- 1) **Define a Separate Group Sequence Provider Class: ** You can create a class that
369
- implements the :class: `Symfony\\ Component\\ Validator\\ GroupSequenceProviderInterface `
368
+ 1) **Define a Separate Group Provider Class: ** You can create a class that
369
+ implements the :class: `Symfony\\ Component\\ Validator\\ GroupProviderInterface `
370
370
and handles the dynamic group sequence logic.
371
371
2) **Configure the User with the Provider: ** Use the ``class `` option within the
372
372
:class: `Symfony\\ Component\\ Validator\\ Constraints\\ GroupSequenceProvider `
373
373
attribute to link the entity with the provider class.
374
374
3) **Autowiring or Manual Tagging: ** If autowiring is enabled, your custom provider
375
375
will be automatically linked. Otherwise, you can manually tag your service with
376
- ``validator.group_sequence_provider ``.
376
+ ``validator.group_provider ``.
377
377
378
378
.. configuration-block ::
379
379
@@ -383,9 +383,9 @@ Here's how you can achieve this:
383
383
namespace App\Entity;
384
384
385
385
// ...
386
- use App\Validator\UserGroupSequenceProvider ;
386
+ use App\Validator\UserGroupProvider ;
387
387
388
- #[Assert\GroupSequenceProvider(class: UserGroupSequenceProvider ::class)]
388
+ #[Assert\GroupSequenceProvider(class: UserGroupProvider ::class)]
389
389
class User
390
390
{
391
391
// ...
@@ -395,7 +395,7 @@ Here's how you can achieve this:
395
395
396
396
# config/validator/validation.yaml
397
397
App\Entity\User :
398
- group_sequence_provider : App\Validator\UserGroupSequenceProvider
398
+ group_sequence_provider : App\Validator\UserGroupProvider
399
399
400
400
.. code-block :: xml
401
401
@@ -408,7 +408,7 @@ Here's how you can achieve this:
408
408
409
409
<class name =" App\Entity\User" >
410
410
<group-sequence-provider >
411
- <value >App\Validator\UserGroupSequenceProvider </value >
411
+ <value >App\Validator\UserGroupProvider </value >
412
412
</group-sequence-provider >
413
413
<!-- ... -->
414
414
</class >
@@ -420,7 +420,7 @@ Here's how you can achieve this:
420
420
namespace App\Entity;
421
421
422
422
// ...
423
- use App\Validator\UserGroupSequenceProvider ;
423
+ use App\Validator\UserGroupProvider ;
424
424
use Symfony\Component\Validator\Mapping\ClassMetadata;
425
425
426
426
class User
@@ -429,7 +429,7 @@ Here's how you can achieve this:
429
429
430
430
public static function loadValidatorMetadata(ClassMetadata $metadata): void
431
431
{
432
- $metadata->setGroupSequenceProviderClass(UserGroupSequenceProvider ::class);
432
+ $metadata->setGroupProviderClass(UserGroupProvider ::class);
433
433
$metadata->setGroupSequenceProvider(true);
434
434
// ...
435
435
}
0 commit comments