4

Looking through the Drupal coding conventions on Coding standards / Naming Conventions, I have seen module, variable, function, and many other areas but not for permission names.

Is there any convention to avoid creating permission names that might interfere with others?

2 Answers 2

1

AFAIK there's no official recommendations.

Given that all permissions share the same namespace it's a good idea to avoid generic names. You can include the name of the module that defines the permissions to minimize collision risk.

3
  • Is this still the case for Drupal 8?
    – anoopjohn
    Commented Nov 17, 2019 at 23:36
  • Drupal 8 changes how you declare permissions. Now they are declared in a yml file, with am id, title and desc. I suspect there's no collision problem because there are declared in different yml files, but I can't confirm this.
    – sanzante
    Commented Nov 18, 2019 at 13:07
  • 1
    Looks like this is still the case. Even though we are putting them in yml files you still check for the permission string without any namespace. So there is still the chance for conflict.
    – anoopjohn
    Commented Nov 19, 2019 at 5:40
0

The Drupal coding standards do not say how permissions should be named, especially to avoid collisions between permissions defined from different projects.

The permission names used by Drupal core follow the schema <verb> <object>, as administer users, view user email addresses, administer nodes, and administer content types.
Usually, <object> is derived from the module name, and that avoids conflicts, but that is not always true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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