aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/files/storage
diff options
context:
space:
mode:
authoricewind1991 <robin@icewind.nl>2014-05-30 14:58:59 +0200
committericewind1991 <robin@icewind.nl>2014-05-30 14:58:59 +0200
commit2ba5701b1af3ba37061fa0e5fa85aac7abaabea4 (patch)
tree880ca8c8cfbf48a103b42571645668eb918898c1 /lib/private/files/storage
parent517501ffbf369b24191d8b9a9f2ce44a9891fb97 (diff)
parent998fa2d9be4a876cec00073b0706a793276ddd8f (diff)
downloadnextcloud-server-2ba5701b1af3ba37061fa0e5fa85aac7abaabea4.tar.gz
nextcloud-server-2ba5701b1af3ba37061fa0e5fa85aac7abaabea4.zip
Merge pull request #8778 from owncloud/storage-instanceof
Add storage->instanceOfStorage() to handle instanceof with storage wrappers
Diffstat (limited to 'lib/private/files/storage')
-rw-r--r--lib/private/files/storage/common.php14
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php21
2 files changed, 33 insertions, 2 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index 1ed0d79817b..6b11603323a 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -7,6 +7,7 @@
*/
namespace OC\Files\Storage;
+
use OC\Files\Filesystem;
use OC\Files\Cache\Watcher;
@@ -21,7 +22,6 @@ use OC\Files\Cache\Watcher;
* Some \OC\Files\Storage\Common methods call functions which are first defined
* in classes which extend it, e.g. $this->stat() .
*/
-
abstract class Common implements \OC\Files\Storage\Storage {
protected $cache;
protected $scanner;
@@ -46,7 +46,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
protected function remove($path) {
if ($this->is_dir($path)) {
return $this->rmdir($path);
- } else if($this->is_file($path)) {
+ } else if ($this->is_file($path)) {
return $this->unlink($path);
} else {
return false;
@@ -412,4 +412,14 @@ abstract class Common implements \OC\Files\Storage\Storage {
protected function removeCachedFile($path) {
unset($this->cachedFiles[$path]);
}
+
+ /**
+ * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public function instanceOfStorage($class) {
+ return is_a($this, $class);
+ }
}
diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index 11ea9f71da7..364475a68e0 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -440,4 +440,25 @@ class Wrapper implements \OC\Files\Storage\Storage {
public function isLocal() {
return $this->storage->isLocal();
}
+
+ /**
+ * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public function instanceOfStorage($class) {
+ return is_a($this, $class) or $this->storage->instanceOfStorage($class);
+ }
+
+ /**
+ * Pass any methods custom to specific storage implementations to the wrapped storage
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ */
+ public function __call($method, $args) {
+ return call_user_func_array(array($this->storage, $method), $args);
+ }
}