From 34919d3ebc828314579d180a5ab261b67e6fc03c Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 25 Aug 2019 15:27:04 +0200 Subject: [PATCH 1/2] Add IAppManager::getAppWebPath() Implements a public API for \OC_App::getAppWebPath() Signed-off-by: Daniel Rudolf --- lib/private/App/AppManager.php | 16 ++++++++++++++++ lib/public/App/IAppManager.php | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 322731d677..6571386f5c 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -13,6 +13,7 @@ * @author Robin Appelman * @author Thomas Müller * @author Vincent Petry + * @author Daniel Rudolf * * @license AGPL-3.0 * @@ -403,6 +404,21 @@ class AppManager implements IAppManager { return $appPath; } + /** + * Get the web path for the given app. + * + * @param string $appId + * @return string + * @throws AppPathNotFoundException if app path can't be found + */ + public function getAppWebPath($appId) { + $appWebPath = \OC_App::getAppWebPath($appId); + if($appWebPath === false) { + throw new AppPathNotFoundException('Could not find web path for ' . $appId); + } + return $appWebPath; + } + /** * Clear the cached list of apps when enabling/disabling an app */ diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index aebd47b3a2..c57b94382a 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -8,6 +8,7 @@ * @author Morris Jobke * @author Robin Appelman * @author Thomas Müller + * @author Daniel Rudolf * * @license AGPL-3.0 * @@ -125,6 +126,16 @@ interface IAppManager { */ public function getAppPath($appId); + /** + * Get the web path for the given app. + * + * @param string $appId + * @return string + * @since 17.0.0 + * @throws AppPathNotFoundException + */ + public function getAppWebPath($appId); + /** * List all apps enabled for a user * From 2d56664e3587214254c1fd35370b6854c0ad878b Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 5 Sep 2019 18:35:40 +0200 Subject: [PATCH 2/2] Improve usage of IAppManager::getAppWebPath() Deprecate \OC_App::getAppWebPath() and \OC_App::getAppPath() Signed-off-by: Daniel Rudolf --- lib/private/App/AppManager.php | 2 +- lib/private/legacy/app.php | 2 ++ lib/public/App/IAppManager.php | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 6571386f5c..1924224560 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -411,7 +411,7 @@ class AppManager implements IAppManager { * @return string * @throws AppPathNotFoundException if app path can't be found */ - public function getAppWebPath($appId) { + public function getAppWebPath(string $appId): string { $appWebPath = \OC_App::getAppWebPath($appId); if($appWebPath === false) { throw new AppPathNotFoundException('Could not find web path for ' . $appId); diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 58b617aae4..9e47f9064d 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -485,6 +485,7 @@ class OC_App { * * @param string $appId * @return string|false + * @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath() */ public static function getAppPath(string $appId) { if ($appId === null || trim($appId) === '') { @@ -503,6 +504,7 @@ class OC_App { * * @param string $appId * @return string|false + * @deprecated 18.0.0 use \OC::$server->getAppManager()->getAppWebPath() */ public static function getAppWebPath(string $appId) { if (($dir = self::findAppInDirectories($appId)) != false) { diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index c57b94382a..391e3f0dd6 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -131,10 +131,10 @@ interface IAppManager { * * @param string $appId * @return string - * @since 17.0.0 + * @since 18.0.0 * @throws AppPathNotFoundException */ - public function getAppWebPath($appId); + public function getAppWebPath(string $appId): string; /** * List all apps enabled for a user