Implements hook_entity_info().

3 calls to field_test_entity_info()
field_test_create_bundle in modules/field/tests/field_test.entity.inc
Creates a new bundle for test_entity entities.
field_test_delete_bundle in modules/field/tests/field_test.entity.inc
Deletes a bundle for test_entity objects.
field_test_rename_bundle in modules/field/tests/field_test.entity.inc
Renames a bundle for test_entity entities.

File

modules/field/tests/field_test.entity.inc, line 11
Defines an entity type.

Code

function field_test_entity_info() {

  // If requested, clear the field cache while this hook is being called. See
  // testFieldInfoCache().
  if (variable_get('field_test_clear_info_cache_in_hook_entity_info', FALSE)) {
    field_info_cache_clear();
  }
  $bundles = variable_get('field_test_bundles', array(
    'test_bundle' => array(
      'label' => 'Test Bundle',
    ),
  ));
  $test_entity_modes = array(
    'full' => array(
      'label' => t('Full object'),
      'custom settings' => TRUE,
    ),
    'teaser' => array(
      'label' => t('Teaser'),
      'custom settings' => TRUE,
    ),
  );
  return array(
    'test_entity' => array(
      'label' => t('Test Entity'),
      'fieldable' => TRUE,
      'field cache' => FALSE,
      'base table' => 'test_entity',
      'revision table' => 'test_entity_revision',
      'entity keys' => array(
        'id' => 'ftid',
        'revision' => 'ftvid',
        'bundle' => 'fttype',
      ),
      'bundles' => $bundles,
      'view modes' => $test_entity_modes,
    ),
    // This entity type doesn't get form handling for now...
    'test_cacheable_entity' => array(
      'label' => t('Test Entity, cacheable'),
      'fieldable' => TRUE,
      'field cache' => TRUE,
      'entity keys' => array(
        'id' => 'ftid',
        'revision' => 'ftvid',
        'bundle' => 'fttype',
      ),
      'bundles' => $bundles,
      'view modes' => $test_entity_modes,
    ),
    'test_entity_bundle_key' => array(
      'label' => t('Test Entity with a bundle key.'),
      'base table' => 'test_entity_bundle_key',
      'fieldable' => TRUE,
      'field cache' => FALSE,
      'entity keys' => array(
        'id' => 'ftid',
        'bundle' => 'fttype',
      ),
      'bundles' => array(
        'bundle1' => array(
          'label' => 'Bundle1',
        ),
        'bundle2' => array(
          'label' => 'Bundle2',
        ),
      ) + $bundles,
      'view modes' => $test_entity_modes,
    ),
    // In this case, the bundle key is not stored in the database.
    'test_entity_bundle' => array(
      'label' => t('Test Entity with a specified bundle.'),
      'base table' => 'test_entity_bundle',
      'fieldable' => TRUE,
      'controller class' => 'TestEntityBundleController',
      'field cache' => FALSE,
      'entity keys' => array(
        'id' => 'ftid',
        'bundle' => 'fttype',
      ),
      'bundles' => array(
        'test_entity_2' => array(
          'label' => 'Test entity 2',
        ),
      ) + $bundles,
      'view modes' => $test_entity_modes,
    ),
    // @see EntityPropertiesTestCase::testEntityLabel()
    'test_entity_no_label' => array(
      'label' => t('Test entity without label'),
      'fieldable' => TRUE,
      'field cache' => FALSE,
      'base table' => 'test_entity',
      'entity keys' => array(
        'id' => 'ftid',
        'revision' => 'ftvid',
        'bundle' => 'fttype',
      ),
      'bundles' => $bundles,
      'view modes' => $test_entity_modes,
    ),
    'test_entity_label' => array(
      'label' => t('Test entity label'),
      'fieldable' => TRUE,
      'field cache' => FALSE,
      'base table' => 'test_entity',
      'entity keys' => array(
        'id' => 'ftid',
        'revision' => 'ftvid',
        'bundle' => 'fttype',
        'label' => 'ftlabel',
      ),
      'bundles' => $bundles,
      'view modes' => $test_entity_modes,
    ),
    'test_entity_label_callback' => array(
      'label' => t('Test entity label callback'),
      'fieldable' => TRUE,
      'field cache' => FALSE,
      'base table' => 'test_entity',
      'label callback' => 'field_test_entity_label_callback',
      'entity keys' => array(
        'id' => 'ftid',
        'revision' => 'ftvid',
        'bundle' => 'fttype',
      ),
      'bundles' => $bundles,
      'view modes' => $test_entity_modes,
    ),
  );
}