storage = $storage; } public function updateWorkflow(int $id, array $data): Workflow { // TODO: data & workflow validation (trigger existence, graph consistency, etc.) // TODO: new revisions when content is changed // TODO: validation when status being is changed $workflow = $this->storage->getWorkflow($id); if (!$workflow) { throw Exceptions::workflowNotFound($id); } if (array_key_exists('status', $data)) { $workflow->setStatus($data['status']); $this->storage->updateWorkflow($workflow); } $workflow = $this->storage->getWorkflow($id); if (!$workflow) { throw Exceptions::workflowNotFound($id); } return $workflow; } }