mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
chore: Replace last calls to OC_App::enable by IAppManager
Also added a few missing deprecations Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
61a87bc384
commit
3e01a429e7
4 changed files with 21 additions and 10 deletions
|
|
@ -99,7 +99,7 @@ class Installer {
|
|||
* @param bool $allowUnstable Allow unstable releases
|
||||
*/
|
||||
public function updateAppstoreApp(string $appId, bool $allowUnstable = false): bool {
|
||||
if ($this->isUpdateAvailable($appId, $allowUnstable)) {
|
||||
if ($this->isUpdateAvailable($appId, $allowUnstable) !== false) {
|
||||
try {
|
||||
$this->downloadApp($appId, $allowUnstable);
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -108,7 +108,7 @@ class Installer {
|
|||
]);
|
||||
return false;
|
||||
}
|
||||
return OC_App::updateApp($appId);
|
||||
return $this->appManager->upgradeApp($appId);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -475,8 +475,7 @@ class Installer {
|
|||
$this->downloadApp($appId);
|
||||
}
|
||||
$this->installApp($appId);
|
||||
$app = new OC_App();
|
||||
$app->enable($appId);
|
||||
$this->appManager->enableApp($appId);
|
||||
}
|
||||
$bundles = json_decode($this->config->getAppValue('core', 'installed.bundles', json_encode([])), true);
|
||||
$bundles[] = $bundle->getIdentifier();
|
||||
|
|
|
|||
|
|
@ -389,12 +389,11 @@ class Updater extends BasicEmitter {
|
|||
}
|
||||
$this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
|
||||
|
||||
if (!empty($previousEnableStates)) {
|
||||
$ocApp = new \OC_App();
|
||||
if (isset($previousEnableStates[$app])) {
|
||||
if (!empty($previousEnableStates[$app]) && is_array($previousEnableStates[$app])) {
|
||||
$ocApp->enable($app, $previousEnableStates[$app]);
|
||||
} else {
|
||||
$ocApp->enable($app);
|
||||
$this->appManager->enableAppForGroups($app, $previousEnableStates[$app]);
|
||||
} elseif ($previousEnableStates[$app] === 'yes') {
|
||||
$this->appManager->enableApp($app);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ class OC_App {
|
|||
* @param array $groups (optional) when set, only these groups will have access to the app
|
||||
* @throws \Exception
|
||||
* @return void
|
||||
* @deprecated 32.0.0 Use the installer and the app manager instead
|
||||
*
|
||||
* This function set an app as enabled in appconfig.
|
||||
*/
|
||||
|
|
@ -538,6 +539,9 @@ class OC_App {
|
|||
return $appList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 32.0.0 Use IAppManager::isUpgradeRequired instead
|
||||
*/
|
||||
public static function shouldUpgrade(string $app): bool {
|
||||
return Server::get(\OCP\App\IAppManager::class)->isUpgradeRequired($app);
|
||||
}
|
||||
|
|
@ -557,6 +561,7 @@ class OC_App {
|
|||
* @param array $appInfo app info (from xml)
|
||||
*
|
||||
* @return bool true if compatible, otherwise false
|
||||
* @deprecated 32.0.0 Use IAppManager::isAppCompatible instead
|
||||
*/
|
||||
public static function isAppCompatible(string $ocVersion, array $appInfo, bool $ignoreMax = false): bool {
|
||||
return Server::get(\OCP\App\IAppManager::class)->isAppCompatible($ocVersion, $appInfo, $ignoreMax);
|
||||
|
|
|
|||
|
|
@ -6,10 +6,18 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
use OC\Installer;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Server;
|
||||
|
||||
require_once __DIR__ . '/../lib/base.php';
|
||||
|
||||
function enableApp($app) {
|
||||
(new \OC_App())->enable($app);
|
||||
$installer = Server::get(Installer::class);
|
||||
$appManager = Server::get(IAppManager::class);
|
||||
|
||||
$installer->installApp($app);
|
||||
$appManager->enableApp($app);
|
||||
echo "Enabled application {$app}\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue