api = $api; $this->coreIntegration = $coreIntegration; $this->registry = $registry; $this->stepHandler = $stepHandler; $this->triggerHandler = $triggerHandler; $this->wordPress = $wordPress; $this->workflowStorage = $workflowStorage; } public function initialize(): void { $this->registerApiRoutes(); $this->api->initialize(); $this->stepHandler->initialize(); $this->triggerHandler->initialize(); $this->coreIntegration->register($this->registry); $this->wordPress->doAction(Hooks::INITIALIZE, [$this->registry]); $this->registerActiveTriggerHooks(); } private function registerApiRoutes(): void { $this->wordPress->addAction(Hooks::API_INITIALIZE, function (API $api) { $api->registerGetRoute('workflows', WorkflowsGetEndpoint::class); $api->registerPutRoute('workflows/(?P\d+)', WorkflowsPutEndpoint::class); $api->registerPostRoute('workflows/create-from-template', WorkflowsCreateFromTemplateEndpoint::class); $api->registerPostRoute('system/database', DatabasePostEndpoint::class); $api->registerDeleteRoute('system/database', DatabaseDeleteEndpoint::class); $api->registerGetRoute('workflow-templates', WorkflowTemplatesGetEndpoint::class); }); } private function registerActiveTriggerHooks(): void { $triggerKeys = $this->workflowStorage->getActiveTriggerKeys(); foreach ($triggerKeys as $triggerKey) { $instance = $this->registry->getTrigger($triggerKey); if ($instance) { $instance->registerHooks(); } } } }