function rabbit_hole_entity_get_bundle in Rabbit Hole 7.2
Gets the bundle of an entity.
Parameters
string $entity_type: The entity type for the entity.
object $entity: The entity that we're checking.
Return value
string The machine name for the bundle.
3 calls to rabbit_hole_entity_get_bundle()
- rabbit_hole_execute in ./
rabbit_hole.module - Determines the action that should be executed.
- rabbit_hole_get_action in ./
rabbit_hole.module - Determines the actual action for an entity.
- rabbit_hole_menu_local_tasks_alter in ./
rabbit_hole.module - Implements hook_menu_local_tasks_alter().
File
- ./
rabbit_hole.module, line 638 - Main module file for Rabbit Hole.
Code
function rabbit_hole_entity_get_bundle($entity_type, $entity) {
$entity_info = entity_get_info($entity_type);
// Use the bundle key to get the bundle for this entity if the bundle key has
// been defined. If it hasn't, it means that this entity only provides one
// bundle, and that bundle will always have the same name as the entoty type.
// E.g, the user entity is built by one bundle, and that bundle is also called
// user.
//
// @see hook_entity_info()
return !empty($entity_info['entity keys']['bundle']) ? $entity->{$entity_info['entity keys']['bundle']} : $entity_type;
}