diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-03-06 11:13:29 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2024-03-07 22:40:31 +0100 |
commit | 876e2d6198040553cdf0b184fb585b3b63048a7d (patch) | |
tree | bccdffb7f66222df0f5261c26a38c845a640abe7 /lib/private/App/AppManager.php | |
parent | 26728846b40bb1819ad4de507f397b944d15877b (diff) | |
download | nextcloud-server-876e2d6198040553cdf0b184fb585b3b63048a7d.tar.gz nextcloud-server-876e2d6198040553cdf0b184fb585b3b63048a7d.zip |
feat(AppManager): Provide `getAppIcon` function
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib/private/App/AppManager.php')
-rw-r--r-- | lib/private/App/AppManager.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 5eeb7ef1fbd..5dec4e7ccde 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -56,6 +56,7 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; +use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; use OCP\Settings\IManager as ISettingsManager; @@ -104,9 +105,24 @@ class AppManager implements IAppManager { private ICacheFactory $memCacheFactory, private IEventDispatcher $dispatcher, private LoggerInterface $logger, + private IURLGenerator $urlGenerator, ) { } + public function getAppIcon(string $appId): ?string { + $possibleIcons = [$appId . '.svg', 'app.svg', $appId . '-dark.svg', 'app-dark.svg']; + $icon = null; + foreach ($possibleIcons as $iconName) { + try { + $icon = $this->urlGenerator->imagePath($appId, $iconName); + break; + } catch (\RuntimeException $e) { + // ignore + } + } + return $icon; + } + /** * @return string[] $appId => $enabled */ |