function field_info_bundles

field_info_bundles($entity_type = NULL)

Returns information about existing bundles.

Parameters

$entity_type: The type of entity; e.g. 'node' or 'user'.

Return value

An array of bundles for the $entity_type keyed by bundle name, or, if no $entity_type was provided, the array of all existing bundles, keyed by entity type.

Related topics

File

modules/field/field.info.inc, line 432
Field Info API, providing information about available fields and field types.

Code

function field_info_bundles($entity_type = NULL) {
  $info = entity_get_info();

  if ($entity_type) {
    return isset($info[$entity_type]['bundles']) ? $info[$entity_type]['bundles'] : array();
  }

  $bundles = array();
  foreach ($info as $type => $entity_info) {
    $bundles[$type] = $entity_info['bundles'];
  }
  return $bundles;
}

© 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.info.inc/function/field_info_bundles/7.x