You are here

protected function FieldTimerJsFormatterBase::getTimestamp in Field Timer 2.x

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

Retrieves timestamp from field item.

Parameters

\Drupal\Core\Field\FieldItemInterface $item: Field item.

Return value

int|null Datetime field item timestamp.

5 calls to FieldTimerJsFormatterBase::getTimestamp()
FieldTimerCountdownFormatter::viewElements in src/Plugin/Field/FieldFormatter/FieldTimerCountdownFormatter.php
Builds a renderable array for a field value.
FieldTimerCountdownFormatterBase::preparePluginSettings in src/Plugin/Field/FieldFormatter/FieldTimerCountdownFormatterBase.php
Prepares array of settings used to initialize jQuery plugin.
FieldTimerCountdownLedFormatter::viewElements in src/Plugin/Field/FieldFormatter/FieldTImerCountdownLedFormatter.php
Builds a renderable array for a field value.
FieldTimerCountyFormatter::viewElements in src/Plugin/Field/FieldFormatter/FieldTimerCountyFormatter.php
Builds a renderable array for a field value.
FieldTimerJsFormatterBase::generateJsSettings in src/Plugin/Field/FieldFormatter/FieldTimerJsFormatterBase.php
Generates JS settings for the field.

File

src/Plugin/Field/FieldFormatter/FieldTimerJsFormatterBase.php, line 109

Class

FieldTimerJsFormatterBase
Implementation of formatters that uses JavaScript to render timer/countdown.

Namespace

Drupal\field_timer\Plugin\Field\FieldFormatter

Code

protected function getTimestamp(FieldItemInterface $item) {
  if (!empty($item->date)) {
    return $item->date
      ->getTimestamp();
  }
  return NULL;
}