You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This class selects the groups to apply regarding the role of the current user: if the current user has the `ROLE_ADMIN` role, groups `a` and `b` are returned. In other cases, just `a` is returned.
127
+
128
+
This class is automatically registered as a service thanks to [the autowiring feature of the Symfony Dependency Injection Component](https://symfony.com/doc/current/service_container/autowiring.html).
129
+
130
+
Then, configure the entity class to use this service to retrieve validation groups:
131
+
132
+
```php
133
+
<?php
134
+
135
+
// src/AppBundle/Entity/Book.php
136
+
137
+
namespace AppBundle\Entity;
138
+
139
+
use ApiPlatform\Core\Annotation\ApiResource;
140
+
use AppBundle\Validator\AdminGroupsGenerator;
141
+
use Symfony\Component\Validator\Constraints as Assert;
0 commit comments