Skip to content

Naming conventions

Andy Broomfield edited this page Apr 16, 2021 · 8 revisions

Namespace prefix

Modules or projects that are part of the distribution should start with "LocalGov ".

The human readable name should not include the word Drupal in the module name.

For example: "LocalGov Workflows".

Not: "LocalGovDrupal Workflows"

Content types, paragraphs, views, and modules

The machine name prefix is always a descriptive name with localgov_ prefix.

Fields

  • Fields uses the localgov_ prefix.
  • Fields with no shared storage bundle _ descriptive_name,
  • Fields with shared storage descriptive_name

In all cases this should result in the field starting localgov_ if it's provided by the profile; and encourage site_ for site specific extensions.

Set field prefix to localgov_

Drupal's default field prefix is of course field_ resulting in field names like field_foo. To change this to localgov_, try drush config:set field_ui.settings field_prefix localgov_. Any new field created after this will have the localgov_ prefix e.g. localgov_bar.

@see https://git.drupalcode.org/project/drupal/-/blob/9.0.x/core/modules/field_ui/src/Form/FieldStorageAddForm.php#L187

View Displays

New, and refactored, view displays get descriptive names (rather than page_1 etc.)