summaryrefslogtreecommitdiffstats
path: root/lib/files/mount
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-05-08 22:35:10 +0200
committerRobin Appelman <icewind@owncloud.com>2013-05-08 22:35:10 +0200
commitd97ef0805ba5c5687e0642bb8f7c085966153ac9 (patch)
tree0e4aa6c16637861282e7d8f15e475d5cc206605c /lib/files/mount
parentba9db1964053be769b42452fee65ac4720489f81 (diff)
downloadnextcloud-server-d97ef0805ba5c5687e0642bb8f7c085966153ac9.tar.gz
nextcloud-server-d97ef0805ba5c5687e0642bb8f7c085966153ac9.zip
Add mechanism to allow apps to wraper storage classes
Diffstat (limited to 'lib/files/mount')
-rw-r--r--lib/files/mount/mount.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/files/mount/mount.php b/lib/files/mount/mount.php
index 69b8285ab4c..d25a7b3be6e 100644
--- a/lib/files/mount/mount.php
+++ b/lib/files/mount/mount.php
@@ -23,6 +23,11 @@ class Mount {
private $mountPoint;
/**
+ * @var callable[] $storageWrappers
+ */
+ private $storageWrappers = array();
+
+ /**
* @param string|\OC\Files\Storage\Storage $storage
* @param string $mountpoint
* @param array $arguments (optional)
@@ -62,7 +67,7 @@ class Mount {
private function createStorage() {
if (class_exists($this->class)) {
try {
- return new $this->class($this->arguments);
+ return $this->loadStorage($this->class, $this->arguments);
} catch (\Exception $exception) {
\OC_Log::write('core', $exception->getMessage(), \OC_Log::ERROR);
return null;
@@ -74,6 +79,25 @@ class Mount {
}
/**
+ * allow modifier storage behaviour by adding wrappers around storages
+ *
+ * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage
+ *
+ * @param callable $callback
+ */
+ public function addStorageWrapper($callback) {
+ $this->storageWrappers[] = $callback;
+ }
+
+ private function loadStorage($class, $arguments) {
+ $storage = new $class($arguments);
+ foreach ($this->storageWrappers as $wrapper) {
+ $storage = $wrapper($this->mountPoint, $storage);
+ }
+ return $storage;
+ }
+
+ /**
* @return \OC\Files\Storage\Storage
*/
public function getStorage() {