You are here

public function TransitionSet::getExpectedState in Lightning Scheduler 8

Returns the expected workflow state for a given date and time.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $at: The date and time.

Return value

string|null The expected workflow state for the given date and time. NULL if no workflow state is targeted.

File

src/TransitionSet.php, line 105

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 getExpectedState(DrupalDateTime $at) {
  $at = $at
    ->getTimestamp();
  $data = $this
    ->toArray();
  $filtered_keys = array_filter(array_keys($data), function ($key) use ($at) {
    return $key <= $at;
  });
  if ($filtered_keys) {
    return $data[end($filtered_keys)];
  }
  return NULL;
}