Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityController.php

function 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 347

Class

EntityController
Provides the add-page and title callbacks for entities.

Namespace

Drupal\Core\Entity\Controller

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal