You are here

protected function FieldTimerCountdownLedFormatter::getLayout in Field Timer 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/FieldTImerCountdownLedFormatter.php \Drupal\field_timer\Plugin\Field\FieldFormatter\FieldTimerCountdownLedFormatter::getLayout()

Renders timer/countdown layout.

Return value

string Timer/countdown layout

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

File

src/Plugin/Field/FieldFormatter/FieldTImerCountdownLedFormatter.php, line 158

Class

FieldTimerCountdownLedFormatter
Plugin implementation of the 'field_timer_countdown' formatter.

Namespace

Drupal\field_timer\Plugin\Field\FieldFormatter

Code

protected function getLayout() {
  $layout = '<span class="jquery-countdown-led-display-wrapper">';
  if ($this
    ->getSetting('display_days')) {
    for ($i = $this
      ->getSetting('max_count_of_days'); $i > 0; $i--) {
      $layout .= '<span class="%t% image{d1' . substr('000', 0, $i - 1) . '}"></span>';
    }
    $layout .= '<span class="%t% imageDay"></span><span class="%t% imageSpace"></span>';
  }
  if ($this
    ->getSetting('display_hours')) {
    $layout .= '<span class="%t% image{h10}"></span><span class="%t% image{h1}"></span>';
  }
  if ($this
    ->getSetting('display_minutes')) {
    $layout .= '<span class="%t% imageSep"></span>' . '<span class="%t% image{m10}"></span><span class="%t% image{m1}"></span>';
  }
  if ($this
    ->getSetting('display_seconds')) {
    $layout .= '<span class="%t% imageSep"></span>' . '<span class="%t% image{s10}"></span><span class="%t% image{s1}"></span>';
  }
  return str_replace('%t%', $this
    ->getSetting('countdown_theme'), $layout) . '</span>';
}