Save and load workflows in the new format, update API
[MAILPOET-4523]
This commit is contained in:
committed by
John Oleksowicz
parent
9028ea96ec
commit
1677cc2842
@@ -186,7 +186,9 @@ class Workflow {
|
||||
// TODO: validation
|
||||
$workflow = new self(
|
||||
$data['name'],
|
||||
self::parseSteps(Json::decode($data['steps'])),
|
||||
array_map(function (array $stepData): Step {
|
||||
return Step::fromArray($stepData);
|
||||
}, Json::decode($data['steps'])),
|
||||
new \WP_User((int)$data['author'])
|
||||
);
|
||||
$workflow->id = (int)$data['id'];
|
||||
@@ -197,18 +199,4 @@ class Workflow {
|
||||
$workflow->activatedAt = $data['activated_at'] !== null ? new DateTimeImmutable($data['activated_at']) : null;
|
||||
return $workflow;
|
||||
}
|
||||
|
||||
private static function parseSteps(array $data): array {
|
||||
$steps = [];
|
||||
foreach ($data as $step) {
|
||||
$steps[] = new Step(
|
||||
$step['id'],
|
||||
$step['type'],
|
||||
$step['key'],
|
||||
$step['next_step_id'] ?? null,
|
||||
$step['args'] ?? []
|
||||
);
|
||||
}
|
||||
return $steps;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user