function hook_entity_bundle_info

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

Describe the bundles for entity types.

Bundles can also be defined with the \Drupal\Core\Entity\Attribute\Bundle attribute applied to a bundle class.

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.
  • 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()

\Drupal\Core\Entity\Attribute\Bundle

Related topics

2 functions implement hook_entity_bundle_info()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

EntityTestAttributeBundleClassHooks::entityBundleInfo in core/modules/system/tests/modules/entity_test_attribute_bundle_class/src/Hook/EntityTestAttributeBundleClassHooks.php
Implements hook_entity_bundle_info().
EntityTestHooks::entityBundleInfo in core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php
Implements hook_entity_bundle_info().
1 invocation of hook_entity_bundle_info()
EntityTypeBundleInfo::getAllBundleInfo in core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php
Get the bundle info of all entity types.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 894

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.