mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
allow getting mounts by provider
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
04052a9594
commit
469a684d45
2 changed files with 26 additions and 6 deletions
|
|
@ -75,16 +75,15 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all configured mount points for the user
|
||||
*
|
||||
* @param \OCP\IUser $user
|
||||
* @return \OCP\Files\Mount\IMountPoint[]
|
||||
* @param IUser $user
|
||||
* @param IMountProvider[] $providers
|
||||
* @return IMountPoint[]
|
||||
*/
|
||||
public function getMountsForUser(IUser $user) {
|
||||
private function getMountsForFromProviders(IUser $user, array $providers): array {
|
||||
$loader = $this->loader;
|
||||
$mounts = array_map(function (IMountProvider $provider) use ($user, $loader) {
|
||||
return $provider->getMountsForUser($user, $loader);
|
||||
}, $this->providers);
|
||||
}, $providers);
|
||||
$mounts = array_filter($mounts, function ($result) {
|
||||
return is_array($result);
|
||||
});
|
||||
|
|
@ -94,6 +93,17 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
|
|||
return $this->filterMounts($user, $mounts);
|
||||
}
|
||||
|
||||
public function getMountsForUser(IUser $user): array {
|
||||
return $this->getMountsForFromProviders($user, $this->providers);
|
||||
}
|
||||
|
||||
public function getMountsFromProvider(IUser $user, string $mountProviderClass): array {
|
||||
$providers = array_filter($this->providers, function (IMountProvider $mountProvider) use ($mountProviderClass) {
|
||||
return get_class($mountProvider) === $mountProviderClass;
|
||||
});
|
||||
return $this->getMountsForFromProviders($user, $providers);
|
||||
}
|
||||
|
||||
public function addMountForUser(IUser $user, IMountManager $mountManager) {
|
||||
// shared mount provider gets to go last since it needs to know existing files
|
||||
// to check for name collisions
|
||||
|
|
|
|||
|
|
@ -38,6 +38,16 @@ interface IMountProviderCollection {
|
|||
*/
|
||||
public function getMountsForUser(IUser $user);
|
||||
|
||||
/**
|
||||
* Get the configured mount points for the user from a specific mount provider
|
||||
*
|
||||
* @param \OCP\IUser $user
|
||||
* @param class-string<IMountProvider> $mountProviderClass
|
||||
* @return \OCP\Files\Mount\IMountPoint[]
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function getMountsFromProvider(IUser $user, string $mountProviderClass);
|
||||
|
||||
/**
|
||||
* Get the configured home mount for this user
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue