diff options
author | Joas Schilling <coding@schilljs.com> | 2018-10-17 20:03:44 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:15 +0100 |
commit | 136d2c39ac72f837a3ea9a3f698be963fefb69a3 (patch) | |
tree | 5b6f44f7a8e49a23533060fd50c0bbeccd292ba2 /lib/private/Collaboration/Resources/Manager.php | |
parent | 65a9ab47ea233701b559d08d89e36649a3d5a30b (diff) | |
download | nextcloud-server-136d2c39ac72f837a3ea9a3f698be963fefb69a3.tar.gz nextcloud-server-136d2c39ac72f837a3ea9a3f698be963fefb69a3.zip |
Provider functionality
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Collaboration/Resources/Manager.php')
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index e36c4ab1d38..8302d4a1002 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -25,8 +25,11 @@ namespace OC\Collaboration\Resources; use OCP\Collaboration\Resources\ICollection; use OCP\Collaboration\Resources\IManager; +use OCP\Collaboration\Resources\IProvider; use OCP\Collaboration\Resources\IResource; +use OCP\Collaboration\Resources\ResourceException; use OCP\IDBConnection; +use OCP\IUser; class Manager implements IManager { @@ -55,4 +58,51 @@ class Manager implements IManager { public function getResource(string $type, string $id): IResource { return new Resource($this, $this->connection, $type, $id); } + + /** + * @return IProvider[] + * @since 15.0.0 + */ + public function getProviders(): array { + return []; + } + + /** + * Get the display name of a resource + * + * @param IResource $resource + * @return string + * @since 15.0.0 + */ + public function getName(IResource $resource): string { + foreach ($this->getProviders() as $provider) { + try { + return $provider->getName($resource); + } catch (ResourceException $e) { + } + } + + return ''; + } + + /** + * Can a user/guest access the collection + * + * @param IResource $resource + * @param IUser $user + * @return bool + * @since 15.0.0 + */ + public function canAccess(IResource $resource, IUser $user = null): bool { + foreach ($this->getProviders() as $provider) { + try { + if ($provider->canAccess($resource, $user)) { + return true; + } + } catch (ResourceException $e) { + } + } + + return false; + } } |