Skip to main content
Joachim's blog

Main navigation

  • Home
  • About

Breadcrumb

  1. Home

Using Constants For Permission Names: WHY?

By joachim, Wed, 30/06/2010 - 14:19

I keep seeing this sort of thing in so many modules:

define("MY_MODULE_PERM_ACCESS_WIDGETS", 'access widgets');
// Names changed to protect the guilty ;)

Am I missing something, or is this utterly pointless?

The only advantage I see is that you can change the permission string later on. But you actually can't change a permission string once you've made a release without an almighty amount of work in a hook_update_N()[*] to migrate users' existing permissions, so what is the point of using a constant apart from just creating shouty caps noise?

[*] Is there a helper function in core yet for migrating permission names during updates? There really should be.

Tags

  • drupal
  • code style
  • drupal planet
  • wtf

Frequent tags

  • Drupal Code Builder (9)
  • git (7)
  • module builder (6)
  • 6.x (5)
  • drupal commerce (4)
  • Composer (3)
  • Drush (3)
  • development (3)
  • Entity API (3)
  • Field API (3)
  • patching (3)
  • developer tools (2)
  • Rector (2)
  • wtf (2)
  • contributing code (2)
  • code style (2)
  • contrib module (2)
  • maintaining projects (2)
  • drupal.org (2)
  • debugging (2)
  • tests (2)
  • multisite (2)
  • core (2)
  • issue queue (2)
  • Drupal core (2)
  • roadmap (2)
  • 7.x (2)
  • modules (2)
Powered by Drupal