protected function EntityController::loadBundleDescriptions in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Controller/EntityController.php \Drupal\Core\Entity\Controller\EntityController::loadBundleDescriptions()
Expands the bundle information with descriptions, if known.
Parameters
array $bundles: An array of bundle information.
\Drupal\Core\Entity\EntityTypeInterface $bundle_entity_type: The bundle entity type definition.
Return value
array The expanded array of bundle information.
1 call to EntityController::loadBundleDescriptions()
- EntityController::addPage in core/
lib/ Drupal/ Core/ Entity/ Controller/ EntityController.php - Displays add links for the available bundles.
File
- core/
lib/ Drupal/ Core/ Entity/ Controller/ EntityController.php, line 331
Class
- EntityController
- Provides the add-page and title callbacks for entities.
Namespace
Drupal\Core\Entity\ControllerCode
protected function loadBundleDescriptions(array $bundles, EntityTypeInterface $bundle_entity_type) {
if (!$bundle_entity_type
->entityClassImplements(EntityDescriptionInterface::class)) {
return $bundles;
}
$bundle_names = array_keys($bundles);
$storage = $this->entityTypeManager
->getStorage($bundle_entity_type
->id());
/** @var \Drupal\Core\Entity\EntityDescriptionInterface[] $bundle_entities */
$bundle_entities = $storage
->loadMultiple($bundle_names);
foreach ($bundles as $bundle_name => &$bundle_info) {
if (isset($bundle_entities[$bundle_name])) {
$bundle_info['description'] = $bundle_entities[$bundle_name]
->getDescription();
}
}
return $bundles;
}