Skip to content

Commit

Permalink
WIP: add unregister methods on ExApp unregister
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
  • Loading branch information
andrey18106 committed Apr 17, 2024
1 parent 9b7505a commit bc2886b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/Service/ExAppEventsListenerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
10 changes: 10 additions & 0 deletions lib/Service/ExAppOccService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Service/ExAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit bc2886b

Please sign in to comment.