diff --git a/lib/Service/ExAppEventsListenerService.php b/lib/Service/ExAppEventsListenerService.php index a003d02a..07fa500f 100644 --- a/lib/Service/ExAppEventsListenerService.php +++ b/lib/Service/ExAppEventsListenerService.php @@ -92,6 +92,16 @@ public function getEventsListeners(): array { } } + public function unregisterExAppEventListeners(string $appId): int { + try { + $result = $this->mapper->removeAllByAppId($appId); + } catch (Exception) { + $result = -1; + } + $this->resetCacheEnabled(); + return $result; + } + public function resetCacheEnabled(): void { $this->cache->remove('/ex_events_listener'); } diff --git a/lib/Service/ExAppOccService.php b/lib/Service/ExAppOccService.php index a691a252..04fa1587 100644 --- a/lib/Service/ExAppOccService.php +++ b/lib/Service/ExAppOccService.php @@ -215,6 +215,16 @@ private function buildOptionMode(string $mode): int { }; } + public function unregisterExAppOccCommands(string $appId): int { + try { + $result = $this->mapper->removeAllByAppId($appId); + } catch (Exception) { + $result = -1; + } + $this->resetCacheEnabled(); + return $result; + } + public function resetCacheEnabled(): void { $this->cache->remove('/ex_occ_commands'); } diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index 5845c7e6..f93b022d 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -52,7 +52,8 @@ public function __construct( private readonly TranslationService $translationService, private readonly TalkBotsService $talkBotsService, private readonly SettingsService $settingsService, - private readonly ExAppEventsListenerService $appEventsListenerService, + private readonly ExAppEventsListenerService $eventsListenerService, + private readonly ExAppOccService $occService, ) { $this->cache = $cacheFactory->createDistributed(Application::APP_ID . '/service'); } @@ -110,6 +111,8 @@ public function unregisterExApp(string $appId): bool { $this->translationService->unregisterExAppTranslationProviders($appId); $this->settingsService->unregisterExAppForms($appId); $this->exAppArchiveFetcher->removeExAppFolder($appId); + $this->eventsListenerService->unregisterExAppEventListeners($appId); + $this->occService->unregisterExAppOccCommands($appId); $r = $this->exAppMapper->deleteExApp($appId); if ($r !== 1) { $this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId));