You are here

private static function ComputedCacheFormatterTrait::unitOptions in Computed Field 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/ComputedCacheFormatterTrait.php \Drupal\computed_field\Plugin\Field\FieldFormatter\ComputedCacheFormatterTrait::unitOptions()

List of time options and their factor in seconds to calculate cache seconds

Parameters

$mode string 'singular' or 'plural':

Return value

array

1 call to ComputedCacheFormatterTrait::unitOptions()
ComputedCacheFormatterTrait::settingsForm in src/Plugin/Field/FieldFormatter/ComputedCacheFormatterTrait.php

File

src/Plugin/Field/FieldFormatter/ComputedCacheFormatterTrait.php, line 21

Class

ComputedCacheFormatterTrait
Base formatter trait for computed fields.

Namespace

Drupal\computed_field\Plugin\Field\FieldFormatter

Code

private static function unitOptions($mode) {
  switch ($mode) {
    case 'plural':
      return [
        -1 => t('default'),
        0 => t('off'),
        1 => t('seconds'),
        60 => t('minutes'),
        3600 => t('hours'),
        84400 => t('days'),
      ];
      break;
    case 'singular':
      return [
        1 => t('second'),
        60 => t('minute'),
        3600 => t('hour'),
        84400 => t('day'),
      ];
      break;
    default:
      return [];
  }
}