You are here

protected function AutoEntityLabelManager::getBundleLabel in Automatic Entity Label 8

Same name and namespace in other branches
  1. 8.3 src/AutoEntityLabelManager.php \Drupal\auto_entitylabel\AutoEntityLabelManager::getBundleLabel()
  2. 8.2 src/AutoEntityLabelManager.php \Drupal\auto_entitylabel\AutoEntityLabelManager::getBundleLabel()

Gets the entity bundle label or the entity label.

Return value

string The bundle label.

1 call to AutoEntityLabelManager::getBundleLabel()
AutoEntityLabelManager::getAlternativeLabel in src/AutoEntityLabelManager.php
Gets an alternative entity label.

File

src/AutoEntityLabelManager.php, line 201

Class

AutoEntityLabelManager
AutoEntityLabelManager class.

Namespace

Drupal\auto_entitylabel

Code

protected function getBundleLabel() {
  $entity_type = $this->entity
    ->getEntityTypeId();
  $bundle = $this->entity
    ->bundle();

  // Use the the human readable name of the bundle type. If this entity has no
  // bundle, we use the name of the content entity type.
  if ($bundle != $entity_type) {
    $bundle_entity_type = $this->entityTypeManager
      ->getDefinition($entity_type)
      ->getBundleEntityType();
    $label = $this->entityTypeManager
      ->getStorage($bundle_entity_type)
      ->load($bundle)
      ->label();
  }
  else {
    $label = $this->entityTypeManager
      ->getDefinition($entity_type)
      ->getLabel();
  }
  return $label;
}