You are here

public function PeriodEntityTrait::getStartDate in Recurring Time Period 8

Implements \Drupal\recurring_period\Entity\PeriodEntityInterface::getStartDate().

File

src/Entity/PeriodEntityTrait.php, line 31

Class

PeriodEntityTrait
Provides base fields and accessors for entities that represent a time period.

Namespace

Drupal\recurring_period\Entity

Code

public function getStartDate() {
  if ($this
    ->getEntityType()
    ->hasKey('date_range')) {
    $date_range_field = $this
      ->getEntityType()
      ->getKey('date_range');
    return $this->{$date_range_field}->start_date;
  }
  else {
    $start_date_field = $this
      ->getEntityType()
      ->getKey('start_date');
    return $this->{$start_date_field}->date;
  }
}