You are here

public function EventMeta::isPastEvent in RNG - Events and Registrations 3.x

@inheritDoc

Overrides EventMetaInterface::isPastEvent

File

src/EventMeta.php, line 745

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function isPastEvent($use_end_date = FALSE) {
  $event_type = $this
    ->getEventType();
  $event = $this
    ->getEvent();
  if ($use_end_date) {
    $end_field = $event_type
      ->getEventEndDateField();
    $count = $event
      ->get($end_field)
      ->count();
    $end_value = $event
      ->get($end_field)
      ->get($count - 1);
    if (!empty($end_value->end_value)) {
      $compare_date = $end_value->end_value;
    }
    else {
      $compare_date = $end_value->value;
    }
  }
  else {
    $start_field = $event_type
      ->getEventStartDateField();
    $compare_date = $event
      ->get($start_field)->value;
  }
  return strtotime($compare_date) < time();
}