You are here

public static function UIkitCountdown::preRenderUIkitCountdown in UIkit Components 8.3

Pre-render callback: Sets the countdown attributes.

Doing so during pre_render gives modules a chance to alter the countdown.

Parameters

array $element: A renderable array.

Return value

array A renderable array.

File

src/Element/UIkitCountdown.php, line 82

Class

UIkitCountdown
Provides a render element for the Countdown component.

Namespace

Drupal\uikit_components\Element

Code

public static function preRenderUIkitCountdown($element) {

  // Get the expire date.
  $date = $element['#expire_date'];

  // Set the attributes for the countdown outer element.
  $element['#attributes']
    ->addClass('uk-grid-small');
  $element['#attributes']
    ->addClass('uk-child-width-auto');
  $element['#attributes']
    ->setAttribute('data-uk-grid', '');
  $element['#attributes']
    ->setAttribute('data-uk-countdown', "date: {$date}");
  return $element;
}