You are here

public function DateRecurDate::getValue in Recurring Dates Field 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/DateRecurDate.php \Drupal\date_recur\Plugin\views\field\DateRecurDate::getValue()
  2. 3.x src/Plugin/views/field/DateRecurDate.php \Drupal\date_recur\Plugin\views\field\DateRecurDate::getValue()
  3. 3.1.x src/Plugin/views/field/DateRecurDate.php \Drupal\date_recur\Plugin\views\field\DateRecurDate::getValue()

Gets the value that's supposed to be rendered.

This api exists so that other modules can easy set the values of the field without having the need to change the render method as well.

Parameters

\Drupal\views\ResultRow $values: An object containing all retrieved values.

string $field: Optional name of the field where the value is stored.

Overrides FieldPluginBase::getValue

File

src/Plugin/views/field/DateRecurDate.php, line 26

Class

DateRecurDate
Date field.

Namespace

Drupal\date_recur\Plugin\views\field

Code

public function getValue(ResultRow $values, $field = NULL) : ?int {
  $value = parent::getValue($values, $field);
  assert(isset($this->configuration['source date format']));
  $sourceDateFormat = $this->configuration['source date format'];
  $timeZone = new \DateTimeZone($this->configuration['source time zone']);
  if (isset($value)) {
    $date = DrupalDateTime::createFromFormat($sourceDateFormat, $value, $timeZone);
    return $date
      ->getTimestamp();
  }
  return NULL;
}