summaryrefslogtreecommitdiff
path: root/modules/field/tests/field_test.entity.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-11-05 19:57:28 +0000
committerDries Buytaert <dries@buytaert.net>2010-11-05 19:57:28 +0000
commit4a5e9447c00ab79030cd7b98b5c79bab1a6236fb (patch)
treefa2a0f0042fbf0183e4127906e23618b97294f7a /modules/field/tests/field_test.entity.inc
parent4a110ab715d6a98f8ec46944071df484b8feb062 (diff)
downloadbrdo-4a5e9447c00ab79030cd7b98b5c79bab1a6236fb.tar.gz
brdo-4a5e9447c00ab79030cd7b98b5c79bab1a6236fb.tar.bz2
- Patch #938462 by bojanz: Fix EntityFieldQuery fatal error in certain cases and document bundle limitations.
Diffstat (limited to 'modules/field/tests/field_test.entity.inc')
-rw-r--r--modules/field/tests/field_test.entity.inc21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/field/tests/field_test.entity.inc b/modules/field/tests/field_test.entity.inc
index 353bb3de0..37695bd49 100644
--- a/modules/field/tests/field_test.entity.inc
+++ b/modules/field/tests/field_test.entity.inc
@@ -62,13 +62,16 @@ function field_test_entity_info() {
'bundles' => array('bundle1' => array('label' => 'Bundle1'), 'bundle2' => array('label' => 'Bundle2')),
'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')),
'view modes' => $test_entity_modes,
@@ -409,3 +412,21 @@ function field_test_entity_form_submit_builder($form, &$form_state) {
entity_form_submit_build_entity('test_entity', $entity, $form, $form_state);
return $entity;
}
+
+/**
+ * Controller class for the test_entity_bundle entity type.
+ *
+ * This extends the DrupalDefaultEntityController class, adding required
+ * special handling for bundles (since they are not stored in the database).
+ */
+class TestEntityBundleController extends DrupalDefaultEntityController {
+
+ protected function attachLoad(&$entities, $revision_id = FALSE) {
+ // Add bundle information.
+ foreach ($entities as $key => $entity) {
+ $entity->fttype = 'test_entity_bundle';
+ $entities[$key] = $entity;
+ }
+ parent::attachLoad($entities, $revision_id);
+ }
+}