You are here

function rooms_unit_entity_info in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Implements hook_entity_info().

File

modules/rooms_unit/rooms_unit.module, line 45
Manage units - Units are things that can be booked on a nightly basis (e.g. rooms - but also villas bungalows, etc).

Code

function rooms_unit_entity_info() {
  $return['rooms_unit'] = array(
    'label' => t('Bookable Units'),
    // The entity class and controller class extend the classes provided by the
    // Entity API.
    'entity class' => 'RoomsUnit',
    'controller class' => 'RoomsUnitController',
    'base table' => 'rooms_units',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'unit_id',
      'bundle' => 'type',
      'label' => 'name',
    ),
    // Bundles are defined by the unit types 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' => 'rooms_unit_create',
    'access callback' => 'rooms_unit_access',
    'access arguments' => array(
      'user key' => 'uid',
      'access tag' => 'rooms_unit_access',
    ),
    'permission labels' => array(
      'singular' => t('bookable unit'),
      'plural' => t('bookable units'),
    ),
    'module' => 'rooms_unit',
    // The information below is used by the RoomsRoomUIController (which extends
    // the EntityDefaultUIController).
    'admin ui' => array(
      'path' => 'admin/rooms/units',
      'file' => 'rooms_unit.admin.inc',
      'controller class' => 'RoomsUnitUIController',
      'menu wildcard' => '%rooms_unit',
    ),
    'translation' => array(
      'entity_translation' => array(
        'base path' => 'admin/rooms/units/unit/%rooms_unit',
        'default settings' => array(
          'default_language' => LANGUAGE_NONE,
          'hide_language_selector' => FALSE,
        ),
      ),
    ),
  );

  // The entity that holds information about the entity types.
  $return['rooms_unit_type'] = array(
    'label' => t('Bookable Unit Type'),
    'entity class' => 'RoomsUnitType',
    'controller class' => 'RoomsUnitTypeController',
    'base table' => 'rooms_unit_type',
    'fieldable' => TRUE,
    'bundle of' => 'rooms_unit',
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'type',
      'label' => 'label',
    ),
    'access callback' => 'rooms_unit_type_access',
    'module' => 'rooms_unit',
    // Enable the entity API's admin UI.
    'admin ui' => array(
      'path' => 'admin/rooms/units/unit-types',
      'file' => 'rooms_unit_type.admin.inc',
      'controller class' => 'RoomsUnitTypeUIController',
    ),
  );
  return $return;
}