1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Ecodev\Felix\Api\Field; |
||
6 | |||
7 | use Ecodev\Felix\Acl\Acl; |
||
8 | use Ecodev\Felix\Acl\MultipleRoles; |
||
9 | use Ecodev\Felix\Api\Output\AclResourceConfigurationType; |
||
10 | use GraphQL\Type\Definition\EnumType; |
||
11 | use GraphQL\Type\Definition\Type; |
||
12 | |||
13 | /** |
||
14 | * @phpstan-import-type PermissiveFieldsConfig from FieldInterface |
||
15 | */ |
||
16 | abstract class AclConfiguration |
||
17 | { |
||
18 | /** |
||
19 | * Return the single field configuration, including its name. |
||
20 | * |
||
21 | * @return PermissiveFieldsConfig |
||
22 | */ |
||
23 | public static function build(Acl $acl, EnumType $roleType): iterable |
||
24 | { |
||
25 | yield 'aclConfiguration' => fn () => [ |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
26 | 'name' => 'aclConfiguration', |
||
27 | 'type' => Type::nonNull(Type::listOf(Type::nonNull(_types()->get(AclResourceConfigurationType::class)))), |
||
28 | 'description' => 'User friendly configuration of the ACL', |
||
29 | 'args' => [ |
||
30 | 'roles' => Type::nonNull(Type::listOf(Type::nonNull($roleType))), |
||
31 | ], |
||
32 | 'resolve' => function ($root, array $args) use ($acl): array { |
||
33 | $roles = $args['roles']; |
||
34 | $result = $acl->show(new MultipleRoles($roles)); |
||
35 | |||
36 | return $result; |
||
37 | }, |
||
38 | ]; |
||
39 | } |
||
40 | } |
||
41 |