You are here

public function TransitionSet::toJson 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::toJSON()

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

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

Class

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

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