public function FieldTimerCountdownLedFormatter::viewElements in Field Timer 2.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldFormatter/FieldTImerCountdownLedFormatter.php \Drupal\field_timer\Plugin\Field\FieldFormatter\FieldTimerCountdownLedFormatter::viewElements()
Builds a renderable array for a field value.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.
string $langcode: The language that should be used to render the field.
Return value
array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.
Overrides FieldTimerJsFormatterBase::viewElements
File
- src/
Plugin/ Field/ FieldFormatter/ FieldTImerCountdownLedFormatter.php, line 61
Class
- FieldTimerCountdownLedFormatter
- Plugin implementation of the 'field_timer_countdown' formatter.
Namespace
Drupal\field_timer\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = parent::viewElements($items, $langcode);
$keys = $this
->getItemKeys($items);
foreach ($items as $delta => $item) {
$layout = $this
->getLayout();
$elements[$delta] = [
'#markup' => '<div class="field-timer-jquery-countdown-led ' . $this
->getSetting('countdown_theme') . '" data-field-timer-key="' . $keys[$delta] . '" data-timestamp="' . $this
->getTimestamp($item) . '">' . $layout . '</div>',
];
}
return $elements;
}