summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-05-29 13:45:50 +0200
committerRobin Appelman <icewind@owncloud.com>2014-05-29 13:45:50 +0200
commit8c5521fdfc2e9e85037c61cd77a254e3b7cd1b94 (patch)
tree27177b95cde27fa7e080f8db29c50926969ac4e2 /lib
parentc0f02be50a293c15007eea5a055dc2cd055561fc (diff)
downloadnextcloud-server-8c5521fdfc2e9e85037c61cd77a254e3b7cd1b94.tar.gz
nextcloud-server-8c5521fdfc2e9e85037c61cd77a254e3b7cd1b94.zip
Add $storage->instanceOfStorage to handle instanceof for storage wrappers
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/common.php14
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php10
-rw-r--r--lib/public/files/storage.php8
3 files changed, 30 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..dd2f76e05b8 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -440,4 +440,14 @@ 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);
+ }
}
diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php
index 5ec8ac6245c..323d20db564 100644
--- a/lib/public/files/storage.php
+++ b/lib/public/files/storage.php
@@ -327,4 +327,12 @@ interface Storage {
* @return bool true if the files are stored locally, false otherwise
*/
public function 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);
}