You are here

function feeds_entity_processor_test_entity_info in Feeds entity processor 7

Implements hook_entity_info().

File

tests/modules/feeds_entity_processor_test/feeds_entity_processor_test.module, line 11
Helper module for Feeds entity processor tests.

Code

function feeds_entity_processor_test_entity_info() {
  $items['feeds_entity_processor_test'] = array(
    'label' => t('Test entity'),
    'plural label' => t('Test entities'),
    'description' => t('An entity type used by the Feeds entity processor tests.'),
    'entity class' => 'Entity',
    'controller class' => 'EntityAPIController',
    'base table' => 'feeds_entity_processor_test',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'label' => 'title',
      'bundle' => 'type',
    ),
    'bundles' => array(),
    'bundle keys' => array(
      'bundle' => 'name',
    ),
    'label callback' => 'entity_class_label',
    'uri callback' => 'entity_class_uri',
    'access callback' => 'feeds_entity_processor_test_access',
    'module' => 'feeds_entity_processor_test',
    'metadata controller class' => 'FeedsEntityProcessorTestMetadataController',
  );
  $items['feeds_entity_processor_test_type'] = array(
    'label' => t('Test entity type'),
    'entity class' => 'Entity',
    'controller class' => 'EntityAPIControllerExportable',
    'base table' => 'feeds_entity_processor_test_type',
    'fieldable' => FALSE,
    'bundle of' => 'feeds_entity_processor_test',
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'name',
    ),
    'module' => 'feeds_entity_processor_test',
  );

  // Add bundle info but bypass entity_load() as we cannot use it here.
  $types = db_select('feeds_entity_processor_test_type', 'et')
    ->fields('et')
    ->execute()
    ->fetchAllAssoc('name');
  foreach ($types as $name => $type) {
    $items['feeds_entity_processor_test']['bundles'][$name] = array(
      'label' => $type->label,
    );
  }
  return $items;
}