You are here

private function ItemHistory::formatAction in Library 8

Format the action.

Parameters

string $action: Action machine name.

int $legacy_state_change: Integer value for unported states.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup|null|string Formatted action.

1 call to ItemHistory::formatAction()
ItemHistory::showHistoryForItem in src/Controller/ItemHistory.php
History for one item.

File

src/Controller/ItemHistory.php, line 167

Class

ItemHistory
Item history controller.

Namespace

Drupal\library\Controller

Code

private function formatAction($action, $legacy_state_change) {
  $actionLabel = '';
  if ($action) {
    $actionEntity = LibraryAction::load($action);
    if ($actionEntity) {
      $actionLabel = $actionEntity
        ->label();
    }
    else {
      if ($legacy_state_change == LibraryAction::CHANGE_TO_AVAILABLE) {
        $actionLabel = $this
          ->t('Item became available');
      }
      elseif ($legacy_state_change == LibraryAction::CHANGE_TO_UNAVAILABLE) {
        $actionLabel = $this
          ->t('Item became unavailable');
      }
    }
  }
  return $actionLabel;
}