You are here

public function BackgroundImage::getTypeLabel in Background Image 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/BackgroundImage.php \Drupal\background_image\Entity\BackgroundImage::getTypeLabel()
  2. 2.x src/Entity/BackgroundImage.php \Drupal\background_image\Entity\BackgroundImage::getTypeLabel()

The type label.

Parameters

bool $link: Whether or not to link to the target entity, if one exists.

Return value

\Drupal\Component\Render\MarkupInterface|string

Overrides BackgroundImageInterface::getTypeLabel

File

src/Entity/BackgroundImage.php, line 572

Class

BackgroundImage
Defines the Background Image entity.

Namespace

Drupal\background_image\Entity

Code

public function getTypeLabel($link = FALSE) {
  if (!isset($type)) {
    $type = $this
      ->getType();
  }
  $types = self::getTypes();
  if (!isset($types[$type])) {
    return $this
      ->t('Unknown');
  }
  if ($label = $this
    ->label($link)) {
    if ($type === self::TYPE_ENTITY || $type === self::TYPE_ENTITY_BUNDLE || $type === self::TYPE_VIEW) {
      return $label;
    }
    return new FormattableMarkup('@type: @label', [
      '@type' => $types[$type],
      '@label' => $label,
    ]);
  }
  return $types[$type];
}