summaryrefslogtreecommitdiffstats
path: root/lib/private/files/config
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-11-24 15:54:42 +0100
committerRobin Appelman <icewind@owncloud.com>2014-12-04 16:47:27 +0100
commitf4701d7721453b8356a5be401bb5063d22f851c6 (patch)
treeb27f76b8c02e658ac5e4b599a0ee4e4839b5de19 /lib/private/files/config
parentf3213571bb2609a7f279fd5254f872083b3ea91a (diff)
downloadnextcloud-server-f4701d7721453b8356a5be401bb5063d22f851c6.tar.gz
nextcloud-server-f4701d7721453b8356a5be401bb5063d22f851c6.zip
Add public api for mount configurations
Diffstat (limited to 'lib/private/files/config')
-rw-r--r--lib/private/files/config/mountprovidercollection.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/private/files/config/mountprovidercollection.php b/lib/private/files/config/mountprovidercollection.php
new file mode 100644
index 00000000000..49d026f1bda
--- /dev/null
+++ b/lib/private/files/config/mountprovidercollection.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files\Config;
+
+use OCP\Files\Config\IMountProviderCollection;
+use OCP\Files\Config\IMountProvider;
+use OCP\Files\Storage\IStorageFactory;
+use OCP\IUser;
+
+class MountProviderCollection implements IMountProviderCollection {
+ /**
+ * @var \OCP\Files\Config\IMountProvider[]
+ */
+ private $providers = array();
+
+ /**
+ * @var \OCP\Files\Storage\IStorageFactory
+ */
+ private $loader;
+
+ /**
+ * @param \OCP\Files\Storage\IStorageFactory $loader
+ */
+ public function __construct(IStorageFactory $loader) {
+ $this->loader = $loader;
+ }
+
+ /**
+ * Get all configured mount points for the user
+ *
+ * @param \OCP\IUser $user
+ * @return \OCP\Files\Mount\IMountPoint[]
+ */
+ public function getMountsForUser(IUser $user) {
+ $loader = $this->loader;
+ return array_reduce($this->providers, function ($mounts, IMountProvider $provider) use ($user, $loader) {
+ return array_merge($mounts, $provider->getMountsForUser($user, $loader));
+ }, array());
+ }
+
+ /**
+ * Add a provider for mount points
+ *
+ * @param \OCP\Files\Config\IMountProvider $provider
+ */
+ public function registerProvider(IMountProvider $provider) {
+ $this->providers[] = $provider;
+ }
+}