Community Documentation

Naming conventions

Last updated February 8, 2013. Created by acrazyanimal on May 27, 2012.
Edited by fmizzell, Kristen Pol. Log in to edit this page.

When it comes to entity labels, there are no worries. However, take special care when choosing your ECK entity's 'machine name'. ECK will check to make sure no other entities with the same 'machine name' conflict before allowing you to create it; however, there are aspects that cannot be checked for.

There have been several reported cases of other conflicts happening. See #1345264: Incompatibility entity type with machine name "category". In this example an entity of type category was defined using ECK; however, the user module has a function called user_category_load(). So, when the entity API tries to call the load hook for the category entity, it checks for all modules essentially calling a hook_category_load which conflicts with the user modules completely separate use of that function name.

Another example is if I were to define an entity called user_profile, it would seem a valid entity name and, thus, would get created. However, again the user module has a template file user-profile.tpl.php that requires certain variables and gets triggered on the path /user-profile. The same path is used by default for the user_profile entity I created using ECK. This again results in a conflict and it all breaks down.

So for machine names, it makes sense to make them as unique as possible and try to avoid commonly used terminology in Drupal. For example, you could prefix all machine names with a project-specific label or acronym such as eck_user_profile or eck_category.

About this page

Drupal version
Drupal 7.x
Level
Beginner
Audience
Programmers, Site administrators, Site builders
Keywords
ECK, entity, machine name

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.