getWebhookFileRegistry()->getOption('webhooks'); $events = $this->getWebhookFileRegistry()->getOption('events'); $webhooks[$webhook->getId()] = $webhook->toArray(); $events[$event] = [$webhook->getId()]; $this->getWebhookFileRegistry()->setOption('webhooks', $webhooks); $this->getWebhookFileRegistry()->setOption('events', $events); $this->getServiceManager()->register( WebhookFileRegistry::SERVICE_ID, $this->getWebhookFileRegistry() ); } private function getWebhookFileRegistry(): WebhookFileRegistry { return $this->getServiceLocator()->get(WebhookFileRegistry::class); } }