Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_info()
  2. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_info()

Describe the bundles for entity types.

Return value

array An associative array of all entity bundles, keyed by the entity type name, and then the bundle name, with the following keys:

  • label: The human-readable name of the bundle.
  • uri_callback: (optional) The same as the 'uri_callback' key defined for the entity type in the EntityTypeManager, but for the bundle only. When determining the URI of an entity, if a 'uri_callback' is defined for both the entity type and the bundle, the one for the bundle is used.
  • translatable: (optional) A boolean value specifying whether this bundle has translation support enabled. Defaults to FALSE.
  • class: (optional) The fully qualified class name for this bundle. If omitted, the class from the entity type definition will be used. Multiple bundles must not use the same subclass. If a class is reused by multiple bundles, an \Drupal\Core\Entity\Exception\AmbiguousBundleClassException will be thrown.

See also

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

hook_entity_bundle_info_alter()

Related topics

1 function implements hook_entity_bundle_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_test_entity_bundle_info in core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_entity_bundle_info().
4 invocations of hook_entity_bundle_info()
EntityTypeBundleInfo::getAllBundleInfo in core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php
EntityTypeBundleInfoTest::testGetAllBundleInfo in core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php
Tests the getAllBundleInfo() method.
EntityTypeBundleInfoTest::testGetAllBundleInfoWithEntityBundleInfo in core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php
@covers ::getAllBundleInfo
EntityTypeBundleInfoTest::testGetBundleInfo in core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php
Tests the getBundleInfo() method.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 887
Hooks and documentation related to entities.

Code

function hook_entity_bundle_info() {
  $bundles['user']['user']['label'] = t('User');
  return $bundles;
}