public function deactivateApp(string
$appId, Context
$context): void
{ /** @var AppEntity|null $app */
$app =
$this->appRepo->
search(new Criteria([$appId]),
$context)->
first();
if (!
$app) { throw AppException::
notFound($appId);
} if (!
$app->
isActive()) { return;
} if (!
$app->
getAllowDisable()) { throw new \
RuntimeException(\
sprintf('App %s can not be deactivated. You have to uninstall the app.',
$app->
getName()));
} $this->activeAppsLoader->
reset();
// throw event before deactivating app in db as theme configs from the app need to be removed beforehand
$event =
new AppDeactivatedEvent($app,
$context);
$this->eventDispatcher->
dispatch($event);
$this->scriptExecutor->
execute(new AppDeactivatedHook($event));
$this->appRepo->
update([['id' =>
$appId, 'active' => false
]],
$context);
$this->templateStateService->
deactivateAppTemplates($appId,
$context);