View source  
  <?php
function computing_entity_info() {
  $return['computing_record'] = array(
    'label' => t('Computing Record'),
    
    'entity class' => 'ComputingRecord',
    'controller class' => 'ComputingRecordController',
    'base table' => 'computing_record',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'bundle' => 'application',
      'label' => 'label',
    ),
    
    'bundles' => array(),
    
    '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',
    
    'module' => 'computing',
  );
  
  $return['computing_application'] = array(
    'label' => t('Computing Application'),
    'entity class' => 'ComputingApplication',
    'controller class' => 'ComputingApplicationController',
    'base table' => 'computing_application',
    'fieldable' => FALSE,
    
    'bundle of' => 'computing_record',
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'application',
      'label' => 'label',
    ),
    'creation callback' => 'computing_application_create_entity',
    
    'access callback' => 'computing_application_entity_access',
    'module' => 'computing',
  );
  return $return;
}
function computing_entity_info_alter(&$entity_info) {
  foreach (computing_get_applications() as $application => $info) {
    $entity_info['computing_record']['bundles'][$application] = array(
      'label' => $info->label,
    );
  }
}
function computing_record_create_entity($values = array()) {
  return entity_get_controller('computing_record')
    ->create($values);
}
function computing_application_create_entity($values = array()) {
  return entity_get_controller('computing_application')
    ->create($values);
}
function computing_record_entity_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  return user_access('administer computing records', $account);
}
function computing_application_entity_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  return user_access('administer computing module', $account);
}
function computing_entity_property_info_alter(&$entity_info) {
  if (isset($entity_info['computing_record'])) {
    $entity_info['computing_record']['properties']['created']['type'] = 'date';
    $entity_info['computing_record']['properties']['changed']['type'] = 'date';
  }
}
class ComputingRecord extends Entity {
  public function __construct($values = array()) {
    parent::__construct($values, 'computing_record');
  }
}
class ComputingApplication extends Entity {
  public function __construct($values = array()) {
    parent::__construct($values, 'computing_application');
  }
}
class ComputingRecordController extends EntityAPIController {
  public function __construct($entityType) {
    parent::__construct($entityType);
  }
  
  public function create(array $values = array()) {
    $timestamp = time();
    $values += array(
      'id' => '',
      'is_new' => TRUE,
      'created' => $timestamp,
      'changed' => $timestamp,
    );
    
    $computing_record = parent::create($values);
    return $computing_record;
  }
}
class ComputingApplicationController extends EntityAPIControllerExportable {
  public function __construct($entityType) {
    parent::__construct($entityType);
  }
  public function create(array $values = array()) {
    
    $values += array(
      'id' => '',
      'is_new' => TRUE,
    );
    $computing_application = parent::create($values);
    return $computing_application;
  }
}