storage = $storage; $this->templateStorage = $templateStorage; } public function createWorkflow(string $slug): Workflow { $template = $this->templateStorage->getTemplateBySlug($slug); if (!$template) { throw UnexpectedValueException::create()->withMessage('Template not found.'); } $workflowId = $this->storage->createWorkflow($template->getWorkflow()); $workflow = $this->storage->getWorkflow($workflowId); if (!$workflow) { throw UnexpectedValueException::create()->withMessage('Workflow not found.'); } return $workflow; } }