You are here

protected function LibraryItemFieldFormatter::checkAvailability in Library 8

Check availability of item.

Parameters

int $in_circulation: Circulation parameter.

int $status: Status parameter.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup Formatted response for user.

1 call to LibraryItemFieldFormatter::checkAvailability()
LibraryItemFieldFormatter::viewElements in src/Plugin/Field/FieldFormatter/LibraryItemFieldFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/LibraryItemFieldFormatter.php, line 75

Class

LibraryItemFieldFormatter
Plugin implementation of the 'library_item_field_formatter' formatter.

Namespace

Drupal\library\Plugin\Field\FieldFormatter

Code

protected function checkAvailability($in_circulation, $status) : TranslatableMarkup {
  if ($in_circulation == LibraryItemInterface::REFERENCE_ONLY) {
    return $this
      ->t('Reference only');
  }
  if ($status == LibraryItemInterface::ITEM_AVAILABLE) {
    return $this
      ->t('Item available');
  }
  return $this
    ->t('Item unavailable');
}