1.20.x field.info.inc 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 633
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;
}