public function ComputedCacheFormatterTrait::settingsSummary in Computed Field 8.2
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldFormatter/ComputedCacheFormatterTrait.php \Drupal\computed_field\Plugin\Field\FieldFormatter\ComputedCacheFormatterTrait::settingsSummary()
1 call to ComputedCacheFormatterTrait::settingsSummary()
- ComputedStringFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ ComputedStringFormatter.php
1 method overrides ComputedCacheFormatterTrait::settingsSummary()
- ComputedStringFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ ComputedStringFormatter.php
File
- src/
Plugin/ Field/ FieldFormatter/ ComputedCacheFormatterTrait.php, line 87
Class
- ComputedCacheFormatterTrait
- Base formatter trait for computed fields.
Namespace
Drupal\computed_field\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$cache_duration = (int) $this
->getSetting('cache_duration');
$cache_unit = $this
->getSetting('cache_unit');
$mode = $cache_duration == 1 ? 'singular' : 'plural';
$summary = parent::settingsSummary();
if ($cache_unit < 0) {
$summary[] = t('Cache: default');
}
elseif ($cache_unit == 0) {
// off
$summary[] = t('Cache: <b>off</b>');
}
elseif ($cache_unit == 1) {
// seconds
$summary[] = t('Cache: @duration @unit', $args = [
'@duration' => $cache_duration,
'@unit' => $this
->unitOptions($mode)[$cache_unit],
]);
}
else {
$summary[] = t('Cache: @duration @unit (@seconds seconds)', $args = [
'@duration' => $cache_duration,
'@unit' => $this
->unitOptions($mode)[$cache_unit],
'@seconds' => $cache_duration * $cache_unit,
]);
}
return $summary;
}