Spawned from Drupal Core issue: #1042822.
I routinely need to handle entities and their fields in a generic manner. For some reason an entity object doesn't have a property to describe what kind of entity it actually (i.e.: node, user, comment).
This module is incredibly simple, it adds a property called base_type to a entity in hook_entity_load.
A common scenario is using field_get_items($entity_type, $entity, $field_name, $langcode = NULL) where it needs the $entity_type. If you're handling fields in a generic manner, you won't have access to the entity type.
Scenario problem:
/* ... */
field_get_items('?????', $entity, $field_name);
Example solution with Entity Base Type enabled:
/* ... */
field_get_items($entity->base_type, $entity, $field_name);
Why is the new property called "base_type" and not "entity_type"?
I didn't want to conflict with OG's similar situation where it adds "entity_type" to its objects.
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Developer tools
132 sites report using this module
- Created by cravecode on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.

