You are here

protected function ModerationSidebarController::getStateLabel in Moderation Sidebar 8

Gets the Moderation State label of a given Entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: An entity.

Return value

string The state label.

2 calls to ModerationSidebarController::getStateLabel()
ModerationSidebarController::sideBar in src/Controller/ModerationSidebarController.php
Displays information relevant to moderating an entity in-line.
ModerationSidebarController::translateOverview in src/Controller/ModerationSidebarController.php
Generate a simple list of translations with quick-add buttons.

File

src/Controller/ModerationSidebarController.php, line 687

Class

ModerationSidebarController
Endpoints for the Moderation Sidebar module.

Namespace

Drupal\moderation_sidebar\Controller

Code

protected function getStateLabel(ContentEntityInterface $entity) {
  if ($this->moderationInformation
    ->isModeratedEntity($entity)) {
    $state = $this
      ->getModerationState($entity);
    $state_label = $state
      ->label();
  }
  elseif ($entity instanceof EntityPublishedInterface) {
    $state_label = $entity
      ->isPublished() ? $this
      ->t('Published') : $this
      ->t('Unpublished');
  }
  else {
    $state_label = $this
      ->t('Published');
  }
  return $state_label;
}