You are here

public function ViewmodepagePattern::getViewModeLabel in View Mode Page 8.3

Same name and namespace in other branches
  1. 4.0.x src/Entity/ViewmodepagePattern.php \Drupal\view_mode_page\Entity\ViewmodepagePattern::getViewModeLabel()
  2. 3.2.x src/Entity/ViewmodepagePattern.php \Drupal\view_mode_page\Entity\ViewmodepagePattern::getViewModeLabel()

Gets the label of view_mode.

Return value

string Returns the label of view_mode.

Overrides ViewmodepagePatternInterface::getViewModeLabel

File

src/Entity/ViewmodepagePattern.php, line 234

Class

ViewmodepagePattern
Defines the Viewmodepage pattern entity.

Namespace

Drupal\view_mode_page\Entity

Code

public function getViewModeLabel() {
  $view_mode = $this
    ->getViewMode();
  if ($entity_type_id = $this
    ->getAliasType()
    ->getDerivativeId()) {

    /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository */
    $entity_display_repository = \Drupal::service('entity_display.repository');
    $view_modes = $entity_display_repository
      ->getViewModeOptions($entity_type_id);
    if (!empty($view_modes[$view_mode])) {
      return $view_modes[$view_mode];
    }
  }
  return $view_mode;
}