function entity_get_bundles

Returns the entity bundle info.

Parameters

string|null $entity_type: The entity type whose bundle info should be returned, or NULL for all bundles info. Defaults to NULL.

Return value

array The bundle info for a specific entity type, or all entity types.

30 calls to entity_get_bundles()
1 string reference to 'entity_get_bundles'

File

drupal/core/includes/entity.inc, line 59
Entity API for handling entities like nodes or users.

Code

function entity_get_bundles($entity_type = NULL) {
  $bundles =& drupal_static(__FUNCTION__);
  if (!$bundles) {
    $langcode = language(Language::TYPE_INTERFACE)->langcode;
    if ($cache = cache()
      ->get("entity_bundle_info:{$langcode}")) {
      $bundles = $cache->data;
    }
    else {
      $bundles = module_invoke_all('entity_bundle_info');

      // If no bundles are provided, use the entity type name and label.
      foreach (entity_get_info() as $type => $entity_info) {
        if (!isset($bundles[$type])) {
          $bundles[$type][$type]['label'] = $entity_info['label'];
        }
      }
      drupal_alter('entity_bundle_info', $bundles);
      cache()
        ->set("entity_bundle_info:{$langcode}", $bundles, CacheBackendInterface::CACHE_PERMANENT, array(
        'entity_info' => TRUE,
      ));
    }
  }
  if (empty($entity_type)) {
    return $bundles;
  }
  elseif (isset($bundles[$entity_type])) {
    return $bundles[$entity_type];
  }
  return array();
}