diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-01-23 17:48:24 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:17 +0100 |
commit | 88aa3de7842a5113de5f137ba57bdae1f77777b5 (patch) | |
tree | 41be56cdfaa58851e271e59433a895240555ed26 /lib | |
parent | 555afff015ec2fa785726bf0d9169d25d53ba679 (diff) | |
download | nextcloud-server-88aa3de7842a5113de5f137ba57bdae1f77777b5.tar.gz nextcloud-server-88aa3de7842a5113de5f137ba57bdae1f77777b5.zip |
Add iconClass to resources
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 16 | ||||
-rw-r--r-- | lib/private/Collaboration/Resources/Resource.php | 15 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/IProvider.php | 9 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/IResource.php | 6 |
4 files changed, 46 insertions, 0 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index 82a14f47d9e..cc09089c711 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -120,6 +120,22 @@ class Manager implements IManager { } /** + * + * @param IResource $resource + * @return string + */ + public function getIconClass(IResource $resource): string { + foreach ($this->getProviders() as $provider) { + try { + return $provider->getIconClass($resource); + } catch (ResourceException $e) { + } + } + + return ''; + } + + /** * Can a user/guest access the collection * * @param IResource $resource diff --git a/lib/private/Collaboration/Resources/Resource.php b/lib/private/Collaboration/Resources/Resource.php index 3013f1f5c48..2f491663a88 100644 --- a/lib/private/Collaboration/Resources/Resource.php +++ b/lib/private/Collaboration/Resources/Resource.php @@ -47,6 +47,9 @@ class Resource implements IResource { /** @var string|null */ protected $name; + /** @var string|null */ + protected $iconClass; + public function __construct( IManager $manager, IDBConnection $connection, @@ -88,6 +91,18 @@ class Resource implements IResource { } /** + * @return string + * @since 15.0.0 + */ + public function getIconClass(): string { + if ($this->iconClass === null) { + $this->iconClass = $this->manager->getIconClass($this); + } + + return $this->iconClass; + } + + /** * Can a user/guest access the resource * * @param IUser $user diff --git a/lib/public/Collaboration/Resources/IProvider.php b/lib/public/Collaboration/Resources/IProvider.php index bf338113005..c5f6f7ed560 100644 --- a/lib/public/Collaboration/Resources/IProvider.php +++ b/lib/public/Collaboration/Resources/IProvider.php @@ -36,6 +36,15 @@ interface IProvider { public function getName(IResource $resource): string; /** + * Get the icon class of a resource + * + * @param IResource $resource + * @return string + * @since 15.0.0 + */ + public function getIconClass(IResource $resource): string; + + /** * Can a user/guest access the collection * * @param IResource $resource diff --git a/lib/public/Collaboration/Resources/IResource.php b/lib/public/Collaboration/Resources/IResource.php index 242ad9432d0..9a4b2b30d10 100644 --- a/lib/public/Collaboration/Resources/IResource.php +++ b/lib/public/Collaboration/Resources/IResource.php @@ -48,6 +48,12 @@ interface IResource { public function getName(): string; /** + * @return string + * @since 15.0.0 + */ + public function getIconClass(): string; + + /** * Can a user/guest access the resource * * @param IUser $user |