You are here

protected function AutoEntityLabelManager::getAlternativeLabel in Automatic Entity Label 8

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

Gets an alternative entity label.

Return value

string Translated label string.

1 call to AutoEntityLabelManager::getAlternativeLabel()
AutoEntityLabelManager::setLabel in src/AutoEntityLabelManager.php
Sets the automatically generated entity label.

File

src/AutoEntityLabelManager.php, line 280

Class

AutoEntityLabelManager
AutoEntityLabelManager class.

Namespace

Drupal\auto_entitylabel

Code

protected function getAlternativeLabel() {
  $content_type = $this
    ->getBundleLabel();
  if ($this->entity
    ->id()) {
    $label = $this
      ->t('@type @id', [
      '@type' => $content_type,
      '@id' => $this->entity
        ->id(),
    ]);
  }
  else {
    $label = $content_type;
  }
  return $label;
}