diff options
author | Robin Appelman <robin@icewind.nl> | 2016-05-17 21:40:55 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-17 21:40:55 +0200 |
commit | de5b7609f96e166b96b7380e62d32ac51d85d50f (patch) | |
tree | 4abf914475773f70294ad4be8dad6c00871dca37 /lib/private/Files/Config | |
parent | 7dbdf2f7e0192b77761a3f3eb90aa7c39b240e21 (diff) | |
download | nextcloud-server-de5b7609f96e166b96b7380e62d32ac51d85d50f.tar.gz nextcloud-server-de5b7609f96e166b96b7380e62d32ac51d85d50f.zip |
use mount providers to setup home storages (#24567)
Diffstat (limited to 'lib/private/Files/Config')
-rw-r--r-- | lib/private/Files/Config/MountProviderCollection.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index 499fa576fbc..60c90d7a019 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -24,6 +24,7 @@ namespace OC\Files\Config; use OC\Hooks\Emitter; use OC\Hooks\EmitterTrait; +use OCP\Files\Config\IHomeMountProvider; use OCP\Files\Config\IMountProviderCollection; use OCP\Files\Config\IMountProvider; use OCP\Files\Config\IUserMountCache; @@ -35,6 +36,11 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { use EmitterTrait; /** + * @var \OCP\Files\Config\IHomeMountProvider[] + */ + private $homeProviders = []; + + /** * @var \OCP\Files\Config\IMountProvider[] */ private $providers = array(); @@ -78,6 +84,25 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { } /** + * Get the configured home mount for this user + * + * @param \OCP\IUser $user + * @return \OCP\Files\Mount\IMountPoint + * @since 9.1.0 + */ + public function getHomeMountForUser(IUser $user) { + /** @var \OCP\Files\Config\IHomeMountProvider[] $providers */ + $providers = array_reverse($this->homeProviders); // call the latest registered provider first to give apps an opportunity to overwrite builtin + foreach ($providers as $homeProvider) { + if ($mount = $homeProvider->getHomeMountForUser($user, $this->loader)) { + $mount->setMountPoint('/' . $user->getUID()); //make sure the mountpoint is what we expect + return $mount; + } + } + throw new \Exception('No home storage configured for user ' . $user); + } + + /** * Add a provider for mount points * * @param \OCP\Files\Config\IMountProvider $provider @@ -88,6 +113,17 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { } /** + * Add a provider for home mount points + * + * @param \OCP\Files\Config\IHomeMountProvider $provider + * @since 9.1.0 + */ + public function registerHomeProvider(IHomeMountProvider $provider) { + $this->homeProviders[] = $provider; + $this->emit('\OC\Files\Config', 'registerHomeMountProvider', [$provider]); + } + + /** * Cache mounts for user * * @param IUser $user |