function EntityTypeBundleInfo::getAllBundleInfo
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getAllBundleInfo()
- 10 core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getAllBundleInfo()
- 11.x core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php \Drupal\Core\Entity\EntityTypeBundleInfo::getAllBundleInfo()
Overrides EntityTypeBundleInfoInterface::getAllBundleInfo
1 call to EntityTypeBundleInfo::getAllBundleInfo()
- EntityTypeBundleInfo::getBundleInfo in core/
lib/ Drupal/ Core/ Entity/ EntityTypeBundleInfo.php - Gets the bundle info of an entity type.
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityTypeBundleInfo.php, line 87
Class
- EntityTypeBundleInfo
- Provides discovery and retrieval of entity type bundles.
Namespace
Drupal\Core\EntityCode
public function getAllBundleInfo() {
if (empty($this->bundleInfo)) {
$langcode = $this->languageManager
->getCurrentLanguage()
->getId();
if ($cache = $this->cacheGet("entity_bundle_info:{$langcode}")) {
$this->bundleInfo = $cache->data;
}
else {
$this->bundleInfo = $this->moduleHandler
->invokeAll('entity_bundle_info');
foreach ($this->entityTypeManager
->getDefinitions() as $type => $entity_type) {
// First look for entity types that act as bundles for others, load them
// and add them as bundles.
if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
foreach ($this->entityTypeManager
->getStorage($bundle_entity_type)
->loadMultiple() as $entity) {
$this->bundleInfo[$type][$entity->id()]['label'] = $entity->label();
}
}
elseif (!isset($this->bundleInfo[$type])) {
$this->bundleInfo[$type][$type]['label'] = $entity_type->getLabel();
}
}
$this->moduleHandler
->alter('entity_bundle_info', $this->bundleInfo);
$this->cacheSet("entity_bundle_info:{$langcode}", $this->bundleInfo, Cache::PERMANENT, [
'entity_types',
'entity_bundles',
]);
}
}
return $this->bundleInfo;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.