field_test_entity_info

7 field_test.entity.inc field_test_entity_info()
8 field_test.entity.inc field_test_entity_info()

Implements hook_entity_info().

3 calls to field_test_entity_info()

File

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

Code

function field_test_entity_info() {
  $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(
      'name' => 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(
      'name' => 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(
      'name' => 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(
      'name' => 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(
      'name' => 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(
      'name' => 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(
      'name' => 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,
    ),
  );
}
Login or register to post comments