Filesystem: add Mount::findById

This commit is contained in:
Robin Appelman 2013-01-26 23:49:05 +01:00
parent 03b947e3ec
commit 69f11151e9
1 changed files with 17 additions and 1 deletions

View File

@ -9,6 +9,9 @@
namespace OC\Files; namespace OC\Files;
class Mount { class Mount {
/**
* @var Mount[]
*/
static private $mounts = array(); static private $mounts = array();
/** /**
@ -23,7 +26,7 @@ class Mount {
/** /**
* @param string|\OC\Files\Storage\Storage $storage * @param string|\OC\Files\Storage\Storage $storage
* @param string $mountpoint * @param string $mountpoint
* @param array $arguments * @param array $arguments (optional)
*/ */
public function __construct($storage, $mountpoint, $arguments = null) { public function __construct($storage, $mountpoint, $arguments = null) {
if (is_null($arguments)) { if (is_null($arguments)) {
@ -168,4 +171,17 @@ class Mount {
public static function clear() { public static function clear() {
self::$mounts = array(); self::$mounts = array();
} }
/**
* @param string $id
* @return \OC\Files\Storage\Storage
*/
public static function findById($id) {
foreach (self::$mounts as $mount) {
if ($mount->getStorageId() === $id) {
return $mount;
}
}
return null;
}
} }