diff --git a/modules/entity/entity.controller.inc b/modules/entity/entity.controller.inc index 8a34207..b441acb 100644 --- a/modules/entity/entity.controller.inc +++ b/modules/entity/entity.controller.inc @@ -227,6 +227,11 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface { $entities = $passed_ids; } + // Store the entity type in each entity. + foreach ($entities as $entity) { + $entity->entity_type = $this->entityType; + } + return $entities; } diff --git a/modules/entity/tests/entity_crud_hook_test.test b/modules/entity/tests/entity_crud_hook_test.test index 3f18fc8..a63d02d 100644 --- a/modules/entity/tests/entity_crud_hook_test.test +++ b/modules/entity/tests/entity_crud_hook_test.test @@ -91,6 +91,9 @@ class EntityCrudHookTestCase extends DrupalWebTestCase { $this->assertHookMessage('entity_crud_hook_test_entity_load called for type comment'); $this->assertHookMessage('entity_crud_hook_test_comment_load called'); + // Check that the entity type is set correctly. + $this->assertEqual($comment->entity_type, 'comment', t('Entity type is set to %type', array('%type' => 'comment'))); + $_SESSION['entity_crud_hook_test'] = array(); $comment->subject = 'New subject'; comment_save($comment); @@ -137,6 +140,9 @@ class EntityCrudHookTestCase extends DrupalWebTestCase { $this->assertHookMessage('entity_crud_hook_test_entity_load called for type file'); $this->assertHookMessage('entity_crud_hook_test_file_load called'); + // Check that the entity type is set correctly. + $this->assertEqual($file->entity_type, 'file', t('Entity type is set to %type', array('%type' => 'file'))); + $_SESSION['entity_crud_hook_test'] = array(); $file->filename = 'new.entity_crud_hook_test.file'; file_save($file); @@ -183,6 +189,9 @@ class EntityCrudHookTestCase extends DrupalWebTestCase { $this->assertHookMessage('entity_crud_hook_test_entity_load called for type node'); $this->assertHookMessage('entity_crud_hook_test_node_load called'); + // Check that the entity type is set correctly. + $this->assertEqual($node->entity_type, 'node', t('Entity type is set to %type', array('%type' => 'node'))); + $_SESSION['entity_crud_hook_test'] = array(); $node->title = 'New title'; node_save($node); @@ -231,6 +240,9 @@ class EntityCrudHookTestCase extends DrupalWebTestCase { $this->assertHookMessage('entity_crud_hook_test_entity_load called for type taxonomy_term'); $this->assertHookMessage('entity_crud_hook_test_taxonomy_term_load called'); + // Check that the entity type is set correctly. + $this->assertEqual($term->entity_type, 'taxonomy_term', t('Entity type is set to %type', array('%type' => 'taxonomy_term'))); + $_SESSION['entity_crud_hook_test'] = array(); $term->name = 'New name'; taxonomy_term_save($term); @@ -271,6 +283,9 @@ class EntityCrudHookTestCase extends DrupalWebTestCase { $this->assertHookMessage('entity_crud_hook_test_entity_load called for type taxonomy_vocabulary'); $this->assertHookMessage('entity_crud_hook_test_taxonomy_vocabulary_load called'); + // Check that the entity type is set correctly. + $this->assertEqual($vocabulary->entity_type, 'taxonomy_vocabulary', t('Entity type is set to %type', array('%type' => 'taxonomy_vocabulary'))); + $_SESSION['entity_crud_hook_test'] = array(); $vocabulary->name = 'New name'; taxonomy_vocabulary_save($vocabulary); @@ -313,6 +328,9 @@ class EntityCrudHookTestCase extends DrupalWebTestCase { $this->assertHookMessage('entity_crud_hook_test_entity_load called for type user'); $this->assertHookMessage('entity_crud_hook_test_user_load called'); + // Check that the entity type is set correctly. + $this->assertEqual($account->entity_type, 'user', t('Entity type is set to %type', array('%type' => 'user'))); + $_SESSION['entity_crud_hook_test'] = array(); $edit['name'] = 'New name'; $account = user_save($account, $edit);