function EntityTypeBundleInfo::getBundleInfo

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getBundleInfo()
  2. 9 core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getBundleInfo()
  3. 8.9.x core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getBundleInfo()
  4. main core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getBundleInfo()

Gets the bundle info of an entity type.

Parameters

string $entity_type_id: The entity type ID.

Return value

array An array of bundle information where the outer array is keyed by the bundle name, or the entity type name if the entity does not have bundles. The inner arrays are associative arrays of bundle information, such as the label for the bundle.

Overrides EntityTypeBundleInfoInterface::getBundleInfo

1 call to EntityTypeBundleInfo::getBundleInfo()
EntityTypeBundleInfo::getBundleLabels in core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php
Gets an array of bundle labels for an entity type.

File

core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php, line 79

Class

EntityTypeBundleInfo
Provides discovery and retrieval of entity type bundles.

Namespace

Drupal\Core\Entity

Code

public function getBundleInfo($entity_type_id) {
  if (!is_string($entity_type_id)) {
    @trigger_error('Calling ' . __CLASS__ . '::getBundleInfo() with a non-string $entity_type_id is deprecated in drupal:11.3.0 and throws an exception in drupal:12.0.0. See https://www.drupal.org/node/3557136', E_USER_DEPRECATED);
    return [];
  }
  $bundle_info = $this->getAllBundleInfo();
  return $bundle_info[$entity_type_id] ?? [];
}

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