You are here

function bat_unit_entity_info in Booking and Availability Management Tools for Drupal 7

Implements hook_entity_info().

File

modules/bat_unit/bat_unit.module, line 53

Code

function bat_unit_entity_info() {
  $return['bat_unit'] = array(
    'label' => t('Unit'),
    // The entity class and controller class extend the classes provided by the
    // Entity API.
    'entity class' => 'BatUnit',
    'controller class' => 'BatUnitController',
    'base table' => 'bat_units',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'unit_id',
      'bundle' => 'type',
      'label' => 'name',
    ),
    // Bundles are defined by the unit bundles below.
    'bundles' => array(),
    // Bundle keys tell the FieldAPI how to extract information from the bundle
    // objects.
    'bundle keys' => array(
      'bundle' => 'type',
    ),
    'view modes' => array(
      'display' => array(
        'label' => t('Display'),
        'custom settings' => FALSE,
      ),
    ),
    'label callback' => 'entity_class_label',
    'uri callback' => 'entity_class_uri',
    'creation callback' => 'bat_unit_create',
    'access callback' => 'bat_unit_access',
    'access arguments' => array(
      'user key' => 'uid',
      'access tag' => 'bat_unit_access',
    ),
    'permission labels' => array(
      'singular' => t('unit'),
      'plural' => t('units'),
    ),
    'module' => 'bat_unit',
    // The information below is used by the BatUnitUIController (which extends
    // the EntityDefaultUIController).
    'admin ui' => array(
      'path' => 'admin/bat/config/units',
      'file' => 'bat_unit.admin.inc',
      'controller class' => 'BatUnitUIController',
      'menu wildcard' => '%bat_unit',
    ),
    'metadata controller class' => 'BatUnitMetadataController',
    'translation' => array(
      'entity_translation' => array(
        'base path' => 'admin/bat/units/unit/%bat_unit',
        'path wildcard' => '%bat_unit',
        'path schemes' => array(
          'default' => array(),
        ),
        'default settings' => array(
          'default_language' => LANGUAGE_NONE,
          'hide_language_selector' => FALSE,
        ),
      ),
    ),
  );

  // The entity that holds information about the entity types.
  $return['bat_unit_bundle'] = array(
    'label' => t('Unit Bundle'),
    'entity class' => 'BatUnitBundle',
    'controller class' => 'BatUnitBundleController',
    'base table' => 'bat_unit_bundle',
    'fieldable' => TRUE,
    'bundle of' => 'bat_unit',
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'type',
      'label' => 'label',
    ),
    'access callback' => 'bat_unit_bundle_access',
    'module' => 'bat_unit',
    // Enable the entity API's admin UI.
    'admin ui' => array(
      'path' => 'admin/bat/config/unit-bundles',
      'file' => 'bat_unit_bundle.admin.inc',
      'controller class' => 'BatUnitBundleUIController',
    ),
  );
  $return['bat_type'] = array(
    'label' => t('Type'),
    // The entity class and controller class extend the classes provided by the
    // Entity API.
    'entity class' => 'BatType',
    'controller class' => 'BatTypeController',
    'base table' => 'bat_types',
    'revision table' => 'bat_types_revision',
    'revision' => 'vid',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'type_id',
      'revision' => 'revision_id',
      'bundle' => 'type',
      'label' => 'name',
    ),
    // Bundles are defined by the unit bundles below.
    'bundles' => array(),
    // Bundle keys tell the FieldAPI how to extract information from the bundle
    // objects.
    'bundle keys' => array(
      'bundle' => 'type',
    ),
    'view modes' => array(
      'display' => array(
        'label' => t('Display'),
        'custom settings' => FALSE,
      ),
    ),
    'label callback' => 'entity_class_label',
    'uri callback' => 'entity_class_uri',
    'creation callback' => 'bat_type_create',
    'access callback' => 'bat_type_access',
    'access arguments' => array(
      'user key' => 'uid',
      'access tag' => 'bat_type_access',
    ),
    'permission labels' => array(
      'singular' => t('type'),
      'plural' => t('types'),
    ),
    'module' => 'bat_unit',
    // Enable the entity API's admin UI.
    'admin ui' => array(
      'path' => 'admin/bat/config/types',
      'file' => 'bat_type.admin.inc',
      'controller class' => 'BatTypeUIController',
    ),
    'metadata controller class' => 'BatTypeMetadataController',
    // The information below is used by the BatUnitUIController (which extends
    // the EntityDefaultUIController).
    'translation' => array(
      'entity_translation' => array(
        'base path' => 'admin/bat/config/types/manage/%bat_type',
        'path wildcard' => '%bat_type',
        'path schemes' => array(
          'default' => array(),
        ),
        'default settings' => array(
          'default_language' => LANGUAGE_NONE,
          'hide_language_selector' => FALSE,
        ),
      ),
    ),
  );

  // Enable Inline Entity Form support if module is present.
  if (module_exists('inline_entity_form')) {
    $return['bat_type']['inline entity form'] = array(
      'controller' => 'RoomifyTypeInlineEntityFormController',
    );
  }

  // The entity that holds information about the entity types.
  $return['bat_type_bundle'] = array(
    'label' => t('Type Bundle'),
    'entity class' => 'BatTypeBundle',
    'controller class' => 'BatTypeBundleController',
    'base table' => 'bat_type_bundle',
    'fieldable' => TRUE,
    'bundle of' => 'bat_type',
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'type',
      'label' => 'label',
    ),
    'access callback' => 'bat_type_bundle_access',
    'module' => 'bat_unit',
    // Enable the entity API's admin UI.
    'admin ui' => array(
      'path' => 'admin/bat/config/type-bundles',
      'file' => 'bat_type_bundle.admin.inc',
      'controller class' => 'BatTypeBundleUIController',
    ),
  );
  return $return;
}