You are here

function computing_entity_info in Drupal Computing 7.2

Implement hook_entity_info().

File

./computing.entity.inc, line 12
Code for the entity. This does not allow UI to create Computing Record entities or Computing Application entities. It has to be done in program.

Code

function computing_entity_info() {
  $return['computing_record'] = array(
    'label' => t('Computing Record'),
    // The entity class and controller class extend the classes provided by the Entity API
    'entity class' => 'ComputingRecord',
    'controller class' => 'ComputingRecordController',
    'base table' => 'computing_record',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'bundle' => 'application',
      'label' => 'label',
    ),
    // Bundles are defined by the types below. Otherwise required by Drupal Core hook_entity_info().
    'bundles' => array(),
    // Bundle keys tell the FieldAPI how to extract information from the bundle objects
    'bundle keys' => array(
      'bundle' => 'application',
    ),
    'label callback' => 'entity_class_label',
    'uri callback' => 'entity_class_uri',
    'creation callback' => 'computing_record_create_entity',
    'access callback' => 'computing_record_entity_access',
    // this can't be "user_access" because params are provided by entity_access().
    'module' => 'computing',
  );

  // The entity that holds information about the entity types
  $return['computing_application'] = array(
    'label' => t('Computing Application'),
    'entity class' => 'ComputingApplication',
    'controller class' => 'ComputingApplicationController',
    'base table' => 'computing_application',
    'fieldable' => FALSE,
    // specific to EntityAPI only.
    'bundle of' => 'computing_record',
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'application',
      'label' => 'label',
    ),
    'creation callback' => 'computing_application_create_entity',
    // access callback if not set, will deny all access. see entity_access().
    'access callback' => 'computing_application_entity_access',
    'module' => 'computing',
  );
  return $return;
}