registry = $registry; $this->automationValidator = $automationValidator; $this->automationMapper = $automationMapper; } public function handle(Request $request): Response { /** @var string|null $slug - for PHPStan because strval() doesn't accept a value of mixed */ $slug = $request->getParam('slug'); $slug = strval($slug); $template = $this->registry->getTemplate($slug); if (!$template) { throw Exceptions::automationTemplateNotFound($slug); } $automation = $template->createAutomation(); $automation->setId(0); $this->automationValidator->validate($automation); $data = $template->toArray() + [ 'automation' => $this->automationMapper->buildAutomation($automation), ]; return new Response($data); } public static function getRequestSchema(): array { return [ 'slug' => Builder::string()->required(), ]; } }