function field_extract_bundle in Drupal 7
Helper function to extract the bundle name of from a bundle object.
Parameters
$entity_type: The type of $entity; e.g., 'node' or 'user'.
$bundle: The bundle object (or string if bundles for this entity type do not exist as standalone objects).
Return value
The bundle name.
Related topics
4 calls to field_extract_bundle()
- field_ui_display_overview_form in modules/
field_ui/ field_ui.admin.inc - Form constructor for the field display settings for a given view mode.
- field_ui_field_overview_form in modules/
field_ui/ field_ui.admin.inc - Form constructor for the 'Manage fields' form of a bundle.
- field_ui_menu_load in modules/
field_ui/ field_ui.module - Menu loader; Load a field instance based on field and bundle name.
- _field_ui_view_mode_menu_access in modules/
field_ui/ field_ui.module - Menu access callback for the 'view mode display settings' pages.
File
- modules/
field/ field.module, line 1025 - Attach custom data fields to Drupal entities.
Code
function field_extract_bundle($entity_type, $bundle) {
if (is_string($bundle)) {
return $bundle;
}
$info = entity_get_info($entity_type);
if (is_object($bundle) && isset($info['bundle keys']['bundle']) && isset($bundle->{$info['bundle keys']['bundle']})) {
return $bundle->{$info['bundle keys']['bundle']};
}
}