You are here

public function DateRecurDateTimeComputed::getValue in Recurring Dates Field 3.x

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

Gets the data value.

Return value

mixed The data value.

Overrides DateTimeComputed::getValue

File

src/Plugin/Field/DateRecurDateTimeComputed.php, line 19

Class

DateRecurDateTimeComputed
A computed property for dates of date time field items.

Namespace

Drupal\date_recur\Plugin\Field

Code

public function getValue() {
  $hasValueBefore = isset($this->date);
  parent::getValue();
  if (!$hasValueBefore && isset($this->date)) {

    /** @var \Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem $item */
    $item = $this
      ->getParent();
    $this->date
      ->setTimezone(new \DateTimeZone((string) $item->timezone));
  }
  return $this->date;
}