July 2017
Intermediate to advanced
456 pages
11h 32m
English
Adding permissions specific to your module has been moved from the Drupal 7 hook_permissions to a {module}.permissions.yml file. That file contains an element for each permission, along with the human-readable name and description. If we wanted to add a new permission for our module, we would create a mastering_drupal_8.permissions.yml file like:
access test content: title: Access test content restrict access: TRUE description: Whether a user can access test content
You can also add an array for permission_callback array that contains a list of callables that return an array in the same format as the YAML file. For instance, in node.permissions.yml, there is:
permission_callbacks: - \Drupal\node\NodePermissions::nodeTypePermissions ...
Read now
Unlock full access