diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-01-24 13:50:01 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 22:56:17 +0300 |
commit | 506eb885bcaf7d745b417a155defc7c1e0f344c1 (patch) | |
tree | befcc41987dc41476f71859026cd7b6685e14e54 /lib/private | |
parent | d85e3e3a6d775261cd4a504e07b111224cda8fc8 (diff) |
Only call resource provider if type matches
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index 071fa3c9436..1214145bd03 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -110,9 +110,11 @@ class Manager implements IManager { */ public function getName(IResource $resource): string { foreach ($this->getProviders() as $provider) { - try { - return $provider->getName($resource); - } catch (ResourceException $e) { + if ($provider->getType() === $resource->getType()) { + try { + return $provider->getName($resource); + } catch (ResourceException $e) { + } } } @@ -126,9 +128,11 @@ class Manager implements IManager { */ public function getIconClass(IResource $resource): string { foreach ($this->getProviders() as $provider) { - try { - return $provider->getIconClass($resource); - } catch (ResourceException $e) { + if ($provider->getType() === $resource->getType()) { + try { + return $provider->getIconClass($resource); + } catch (ResourceException $e) { + } } } @@ -145,11 +149,13 @@ class Manager implements IManager { */ public function canAccess(IResource $resource, IUser $user = null): bool { foreach ($this->getProviders() as $provider) { - try { - if ($provider->canAccess($resource, $user)) { - return true; + if ($provider->getType() === $resource->getType()) { + try { + if ($provider->canAccess($resource, $user)) { + return true; + } + } catch (ResourceException $e) { } - } catch (ResourceException $e) { } } @@ -162,4 +168,15 @@ class Manager implements IManager { public function registerResourceProvider(IProvider $provider): void { $this->providers[] = $provider; } + + /** + * Get the type of a resource + * + * @param IResource $resource + * @return string + * @since 15.0.0 + */ + public function getType(): string { + return ''; + } } |