field_extract_bundle
function field_extract_bundle
field_extract_bundle($entity_type, $bundle)
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
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']}; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.module/function/field_extract_bundle/7.x