You are here

function entity_get_bundles in Drupal 8

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.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getBundleInfo() for a single bundle, or \Drupal\Core\Entity\EntityTypeBundleInfoInterface::getAllBundleInfo() for all bundles.

See also

https://www.drupal.org/node/3051077

\Drupal\Core\Entity\EntityTypeBundleInfoInterface::getBundleInfo()

\Drupal\Core\Entity\EntityTypeBundleInfoInterface::getAllBundleInfo()

1 call to entity_get_bundles()
EntityLegacyTest::testEntityLegacyCode in core/tests/Drupal/KernelTests/Core/Entity/EntityLegacyTest.php
@expectedDeprecation entity_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity type storage's loadMultiple() method. See https://www.drupal.org/node/2266845 @expectedDeprecation entity_load() is…

File

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

Code

function entity_get_bundles($entity_type = NULL) {
  @trigger_error('entity_get_bundles() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\Entity\\EntityTypeBundleInfoInterface::getBundleInfo() for a single bundle, or \\Drupal\\Core\\Entity\\EntityTypeBundleInfoInterface::getAllBundleInfo() for all bundles. See https://www.drupal.org/node/3051077', E_USER_DEPRECATED);
  if (isset($entity_type)) {
    return \Drupal::entityManager()
      ->getBundleInfo($entity_type);
  }
  else {
    return \Drupal::entityManager()
      ->getAllBundleInfo();
  }
}