You are here

public function TransitionSet::getExpectedState in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8.2 modules/lightning_scheduler/src/TransitionSet.php \Drupal\lightning_scheduler\TransitionSet::getExpectedState()

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

modules/lightning_scheduler/src/TransitionSet.php, line 102

Class

TransitionSet
Represents a set of scheduled transitions for a single entity.

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;
}