mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
chore: Cleanup setAppTypes and move it to AppManager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
13583e8c6b
commit
a3102bb2f0
3 changed files with 25 additions and 32 deletions
|
|
@ -1042,6 +1042,27 @@ class AppManager implements IAppManager {
|
|||
return $cleanAppId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read app types from info.xml and cache them in the database
|
||||
*/
|
||||
public function setAppTypes(string $app, array $appData): void {
|
||||
if (isset($appData['types'])) {
|
||||
$appTypes = implode(',', $appData['types']);
|
||||
} else {
|
||||
$appTypes = '';
|
||||
$appData['types'] = [];
|
||||
}
|
||||
|
||||
$this->config->setAppValue($app, 'types', $appTypes);
|
||||
|
||||
if ($this->hasProtectedAppType($appData['types'])) {
|
||||
$enabled = $this->config->getAppValue($app, 'enabled', 'yes');
|
||||
if ($enabled !== 'yes' && $enabled !== 'no') {
|
||||
$this->config->setAppValue($app, 'enabled', 'yes');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run upgrade tasks for an app after the code has already been updated
|
||||
*
|
||||
|
|
@ -1099,7 +1120,7 @@ class AppManager implements IAppManager {
|
|||
$this->config->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
|
||||
}
|
||||
|
||||
\OC_App::setAppTypes($appId);
|
||||
$this->setAppTypes($appId, $appData);
|
||||
|
||||
$version = $this->getAppVersion($appId);
|
||||
$this->config->setAppValue($appId, 'installed_version', $version);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||
namespace OC;
|
||||
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use OC\App\AppManager;
|
||||
use OC\App\AppStore\AppNotFoundException;
|
||||
use OC\App\AppStore\Bundles\Bundle;
|
||||
use OC\App\AppStore\Fetcher\AppFetcher;
|
||||
|
|
@ -19,7 +20,6 @@ use OC\DB\Connection;
|
|||
use OC\DB\MigrationService;
|
||||
use OC\Files\FilenameValidator;
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\Files;
|
||||
use OCP\HintException;
|
||||
|
|
@ -46,7 +46,7 @@ class Installer {
|
|||
private ITempManager $tempManager,
|
||||
private LoggerInterface $logger,
|
||||
private IConfig $config,
|
||||
private IAppManager $appManager,
|
||||
private AppManager $appManager,
|
||||
private IFactory $l10nFactory,
|
||||
private bool $isCLI,
|
||||
) {
|
||||
|
|
@ -583,7 +583,7 @@ class Installer {
|
|||
$this->config->setAppValue('core', 'public_' . $name, $info['id'] . '/' . $path);
|
||||
}
|
||||
|
||||
\OC_App::setAppTypes($info['id']);
|
||||
$this->appManager->setAppTypes($info['id'], $info);
|
||||
|
||||
return $info['id'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,34 +136,6 @@ class OC_App {
|
|||
return Server::get(IAppManager::class)->isType($app, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* read app types from info.xml and cache them in the database
|
||||
*/
|
||||
public static function setAppTypes(string $app): void {
|
||||
$appManager = Server::get(IAppManager::class);
|
||||
$appData = $appManager->getAppInfo($app);
|
||||
if (!is_array($appData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($appData['types'])) {
|
||||
$appTypes = implode(',', $appData['types']);
|
||||
} else {
|
||||
$appTypes = '';
|
||||
$appData['types'] = [];
|
||||
}
|
||||
|
||||
$config = Server::get(IConfig::class);
|
||||
$config->setAppValue($app, 'types', $appTypes);
|
||||
|
||||
if ($appManager->hasProtectedAppType($appData['types'])) {
|
||||
$enabled = $config->getAppValue($app, 'enabled', 'yes');
|
||||
if ($enabled !== 'yes' && $enabled !== 'no') {
|
||||
$config->setAppValue($app, 'enabled', 'yes');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns apps enabled for the current user.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue