I'm working with hook_entity_info, and I'm defining an entity which will have multiple bundles.

Do I need to define a bundle which has the same name as the entity, or will the base entity become entirely "abstract" once I define entity bundles?

In the below piece of code, I've defined a setting entity which has the bundle generic. Should generic really be called setting, or can i completely regard the entity as an "abstract" concept?

function settings_entity_info() {
  $info['setting'] = array(
    'access callback' => 'settings_entity_access',
    'admin ui' => array(
      'path' => 'admin/structure/settings',
      'controller class' => 'EntityOperationsDefaultAdminUIController',
    'base table' => 'setting',
    'bundle keys' => array(
      'bundle' => 'type',
    'bundles' => array(
      'generic' => array(
        'label' => t('Generic Setting'),
        'admin' => array(
          'path' => 'admin/structure/settings/generic',

1 Answer 1


No, it's not required. It's not necessary to have a bundle whose machine name is the same machine name used for the entity type. And no, defining bundles doesn't make the entity more abstract in any way.

See, for example, node_entity_info(), where none of the content types (which are node bundles) is called node. Vice versa, in user_entity_info() the only bundle is user.
What you can gather from the implementations of hook_entity_info() done from Drupal core modules is that entities with a single bundle use the same machine name for the bundle and the entity. That is not mandatory, though.

What Drupal assumes is that, if hook_entity_info() doesn't define any bundle, the entity has a single bundle named after the entity type. See entity_get_info().

    // If no bundle key is provided, assume a single bundle, named after
    // the entity type.
    if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
      $entity_info[$name]['bundles'] = array(
        $name => array(
          'label' => $entity_info[$name]['label'],

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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