summaryrefslogtreecommitdiffstats
path: root/lib/private/App
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-01-29 13:09:32 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-01-31 14:13:15 +0100
commit19a0a9a4e7e9e511f5f3d99c697e57e7bb0260e6 (patch)
tree6222451aff18bbb4417f9568fec9dccee7ebf721 /lib/private/App
parent142914608307839dca300a2d410b869b6d2d3444 (diff)
downloadnextcloud-server-19a0a9a4e7e9e511f5f3d99c697e57e7bb0260e6.tar.gz
nextcloud-server-19a0a9a4e7e9e511f5f3d99c697e57e7bb0260e6.zip
Move getAppInfo and getAppVersion to IAppManager
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/App')
-rw-r--r--lib/private/App/AppManager.php50
1 files changed, 42 insertions, 8 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index f2b396b29d0..0e921ba1b7f 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -80,6 +80,12 @@ class AppManager implements IAppManager {
/** @var string[] */
private $alwaysEnabled;
+ /** @var array */
+ private $appInfos = [];
+
+ /** @var array */
+ private $appVersions = [];
+
/**
* @param IUserSession $userSession
* @param AppConfig $appConfig
@@ -341,17 +347,45 @@ class AppManager implements IAppManager {
*
* @param string $appId app id
*
+ * @param bool $path
+ * @param null $lang
* @return array app info
- *
- * @internal
*/
- public function getAppInfo($appId) {
- $appInfo = \OC_App::getAppInfo($appId);
- if (!isset($appInfo['version'])) {
- // read version from separate file
- $appInfo['version'] = \OC_App::getAppVersion($appId);
+ public function getAppInfo(string $appId, bool $path = false, $lang = null) {
+ if ($path) {
+ $file = $appId;
+ } else {
+ if ($lang === null && isset($this->appInfos[$appId])) {
+ return $this->appInfos[$appId];
+ }
+ try {
+ $appPath = $this->getAppPath($appId);
+ } catch (AppPathNotFoundException $e) {
+ return null;
+ }
+ $file = $appPath . '/appinfo/info.xml';
+ }
+
+ $parser = new InfoParser($this->memCacheFactory->createLocal('core.appinfo'));
+ $data = $parser->parse($file);
+
+ if (is_array($data)) {
+ $data = \OC_App::parseAppInfo($data, $lang);
+ }
+
+ if ($lang === null) {
+ $this->appInfos[$appId] = $data;
+ }
+
+ return $data;
+ }
+
+ public function getAppVersion(string $appId, bool $useCache = true) {
+ if(!$useCache || !isset($this->appVersions[$appId])) {
+ $appInfo = \OC::$server->getAppManager()->getAppInfo($appId);
+ $this->appVersions[$appId] = ($appInfo !== null) ? $appInfo['version'] : '0';
}
- return $appInfo;
+ return $this->appVersions[$appId];
}
/**