diff options
-rw-r--r-- | lib/private/App/AppManager.php | 39 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 29 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 6 |
3 files changed, 46 insertions, 28 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index bd0d85da0ce..59df44cbd17 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -100,6 +100,7 @@ class AppManager implements IAppManager { /** @var array */ private array $autoDisabledApps = []; + private array $appTypes = []; /** @var array<string, true> */ private array $loadedApps = []; @@ -178,6 +179,42 @@ class AppManager implements IAppManager { } /** + * check if an app is of a specific type + * + * @param string $app + * @param array $types + * @return bool + */ + public function isType(string $app, array $types): bool { + $appTypes = $this->getAppTypes($app); + foreach ($types as $type) { + if (array_search($type, $appTypes) !== false) { + return true; + } + } + return false; + } + + /** + * get the types of an app + * + * @param string $app + * @return string[] + */ + private function getAppTypes(string $app): array { + //load the cache + if (count($this->appTypes) === 0) { + $this->appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); + } + + if (isset($this->appTypes[$app])) { + return explode(',', $this->appTypes[$app]); + } + + return []; + } + + /** * @return array */ public function getAutoDisabledApps(): array { @@ -332,7 +369,7 @@ class AppManager implements IAppManager { if ($ex instanceof ServerNotAvailableException) { throw $ex; } - if (!$this->isShipped($app) && !\OC_App::isType($app, ['authentication'])) { + if (!$this->isShipped($app) && !$this->isType($app, ['authentication'])) { $this->logger->error("App $app threw an error during app.php load and will be disabled: " . $ex->getMessage(), [ 'exception' => $ex, ]); diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 01bce057881..ec57d43f9a6 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -75,7 +75,6 @@ use Psr\Log\LoggerInterface; class OC_App { private static $adminForms = []; private static $personalForms = []; - private static $appTypes = []; private static $altLogin = []; private static $alreadyRegistered = []; public const supportedApp = 300; @@ -199,34 +198,10 @@ class OC_App { * @param string $app * @param array $types * @return bool + * @deprecated 26.0.0 call \OC::$server->get(IAppManager::class)->isType($app, $types) */ public static function isType(string $app, array $types): bool { - $appTypes = self::getAppTypes($app); - foreach ($types as $type) { - if (array_search($type, $appTypes) !== false) { - return true; - } - } - return false; - } - - /** - * get the types of an app - * - * @param string $app - * @return array - */ - private static function getAppTypes(string $app): array { - //load the cache - if (count(self::$appTypes) == 0) { - self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); - } - - if (isset(self::$appTypes[$app])) { - return explode(',', self::$appTypes[$app]); - } - - return []; + return \OC::$server->get(IAppManager::class)->isType($app, $types); } /** diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 51bd5845b7c..8440b757d40 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -197,6 +197,12 @@ interface IAppManager { public function isShipped($appId); /** + * Check if an app is of a specific type + * @since 26.0.0 + */ + public function isType(string $app, array $types): bool; + + /** * @return string[] * @since 9.0.0 */ |