function EntityType::getBundleLabel

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleLabel()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleLabel()
  3. 11.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType::getBundleLabel()

Overrides EntityTypeInterface::getBundleLabel

File

core/lib/Drupal/Core/Entity/EntityType.php, line 709

Class

EntityType
Provides an implementation of an entity type and its metadata.

Namespace

Drupal\Core\Entity

Code

public function getBundleLabel() {
    // If there is no bundle label defined, try to provide some sensible
    // fallbacks.
    if (!empty($this->bundle_label)) {
        return (string) $this->bundle_label;
    }
    elseif ($bundle_entity_type_id = $this->getBundleEntityType()) {
        return (string) \Drupal::entityTypeManager()->getDefinition($bundle_entity_type_id)
            ->getLabel();
    }
    return (string) new TranslatableMarkup('@type_label bundle', [
        '@type_label' => $this->getLabel(),
    ], [], $this->getStringTranslation());
}

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