1 field_test.entity.inc | field_test_entity_info() |
Implements hook_entity_info().
File
- core/
modules/ field/ tests/ field_test/ field_test.entity.inc, line 10 - Defines an entity type.
Code
function field_test_entity_info() {
$bundles = state_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 class' => 'TestEntity',
'controller class' => 'EntityDatabaseStorageController',
'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,
'entity class' => 'TestFieldEntity',
'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,
),
);
}