I want to assign multiple roles in my routing.yml file :
requirements: _role: "['role1', 'role2', 'role3']"
This is what I currently have, and it doesn't work.
Can someone tell me how to add this?
Thanks in advance!
I want to assign multiple roles in my routing.yml file :
requirements: _role: "['role1', 'role2', 'role3']"
This is what I currently have, and it doesn't work.
Can someone tell me how to add this?
Thanks in advance!
I would strongly advise using permissions, not roles. Permissions are super simple to create in D8+, see How do you create a custom permission to administer a custom module?
The Structure of routes documentation says:
_role: A specific Drupal role, for example 'administrator'. You can specify multiple ones via "," for AND and "+" for OR logic.
For example,
_role: organizer,participant,controller
means a Drupal user needs to have all three roles to access the page. Note that, since the roles available may differ between sites, it's recommended to use permission-based access restriction when possible.
So if a user needs all three roles, it's:
_role: 'role1,role2,role3'
or if they just need one of the three roles, it's:
_role: 'role1+role2+role3'