You are here

public function TransitionSet::trim in Lightning Scheduler 8

Removes all transitions older than a given date and time.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $until: The date and time older than which all transitions will be removed.

File

src/TransitionSet.php, line 126

Class

TransitionSet
@internal This is an internal part of Lightning Scheduler and may be changed or removed at any time without warning. It should not be used by external code in any way.

Namespace

Drupal\lightning_scheduler

Code

public function trim(DrupalDateTime $until) {
  $until = $until
    ->getTimestamp();
  while (count($this->dateList) > 0 && $this->dateList[0]->date
    ->getTimestamp() < $until) {
    $this->dateList
      ->removeItem(0);
    $this->stateList
      ->removeItem(0);
  }
}