Refactor dependencies in setAppTypes

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-02-17 15:29:15 +01:00
parent 9dc3b04802
commit 2e15c0d871
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
1 changed files with 8 additions and 6 deletions

View File

@ -303,8 +303,9 @@ class OC_App {
/**
* read app types from info.xml and cache them in the database
*/
public static function setAppTypes($app) {
$appData = self::getAppInfo($app);
public static function setAppTypes(string $app) {
$appManager = \OC::$server->getAppManager();
$appData = $appManager->getAppInfo($app);
if(!is_array($appData)) {
return;
}
@ -316,12 +317,13 @@ class OC_App {
$appData['types'] = [];
}
\OC::$server->getConfig()->setAppValue($app, 'types', $appTypes);
$config = \OC::$server->getConfig();
$config->setAppValue($app, 'types', $appTypes);
if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
$enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'yes');
if ($appManager->hasProtectedAppType($appData['types'])) {
$enabled = $config->getAppValue($app, 'enabled', 'yes');
if ($enabled !== 'yes' && $enabled !== 'no') {
\OC::$server->getConfig()->setAppValue($app, 'enabled', 'yes');
$config->setAppValue($app, 'enabled', 'yes');
}
}
}