1

I have a custom module in Drupal 8 and I have created a role called editor. How do use .permissions.yml in my module to get it to display on the editor's role?

1

Create a file my_module.permissions.yml and add

my permission:
  title: 'This is my custom permission'
  description: 'A custom permission for your.'

Then use your permission in your my_module.routing.yml:

example.name:
  path: '/example/{name}'
  defaults:
    _controller: '\Drupal\example\Controller\ExampleController::content'
  requirements:
    _permission: 'my permission'

Now you can configure your custom permission on admin/people/permissions

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.