You are here

protected function ShareMessageForm::getEntityBundleLabel in Share Message 8

Provides the bundle label with a fallback when not defined.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type we are looking the bundle label for.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The entity bundle label or a fallback label.

1 call to ShareMessageForm::getEntityBundleLabel()
ShareMessageForm::form in src/Form/ShareMessageForm.php
Overrides Drupal\Core\Entity\EntityFormController::form().

File

src/Form/ShareMessageForm.php, line 409

Class

ShareMessageForm
Base form controller for Share Message edit forms.

Namespace

Drupal\sharemessage\Form

Code

protected function getEntityBundleLabel($entity_type) {
  if ($label = $entity_type
    ->getBundleLabel()) {
    return $this
      ->t('@label', [
      '@label' => $label,
    ]);
  }
  $fallback = $entity_type
    ->getLabel();
  if ($bundle_entity_type = $entity_type
    ->getBundleEntityType()) {

    // This is a better fallback.
    $fallback = $this->entityTypeManager
      ->getDefinition($bundle_entity_type)
      ->getLabel();
  }
  return $this
    ->t('@label bundle', [
    '@label' => $fallback,
  ]);
}