You are here

public function TransitionSet::toJSON in Lightning Scheduler 8

Represents the transition set as a JSON string.

Return value

string The transition set as a JSON array of objects, each of which has the following properties:

  • 'state': The targeted workflow state ID.
  • 'when': The UTC date and time of the transition in ISO 8601 format.

File

src/TransitionSet.php, line 80

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 toJSON() {
  $data = [];
  foreach ($this->dateList as $delta => $item) {
    $data[$delta] = [
      'state' => $this->stateList[$delta]->value,
      'when' => $item->date
        ->format('c', [
        'timezone' => 'UTC',
      ]),
    ];
  }
  return Json::encode($data);
}