function field_extract_bundle

Extracts the bundle name 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 in drupal/core/modules/field_ui/field_ui.admin.inc
Returns the built and processed 'Manage display' form of a bundle.
field_ui_field_overview in drupal/core/modules/field_ui/field_ui.admin.inc
Returns the built and processed 'Manage fields' form of a bundle.
field_ui_menu_load in drupal/core/modules/field_ui/field_ui.module
Menu loader callback: Loads a field instance based on field and bundle name.
_field_ui_view_mode_menu_access in drupal/core/modules/field_ui/field_ui.module
Access callback: Checks access for the 'view mode display settings' pages.

File

drupal/core/modules/field/field.module, line 1090
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']};
  }
}