pass mountpoint to storage wrapper callback

This commit is contained in:
Robin Appelman 2015-03-05 12:28:17 +01:00
parent dbade19362
commit e5c8fd37df
3 changed files with 13 additions and 10 deletions

View file

@ -71,9 +71,10 @@ class MountPoint implements IMountPoint {
}
$mountpoint = $this->formatPath($mountpoint);
$this->mountPoint = $mountpoint;
if ($storage instanceof Storage) {
$this->class = get_class($storage);
$this->storage = $this->loader->wrap($mountpoint, $storage);
$this->storage = $this->loader->wrap($this, $storage);
} else {
// Update old classes to new namespace
if (strpos($storage, 'OC_Filestorage_') !== false) {
@ -82,7 +83,6 @@ class MountPoint implements IMountPoint {
$this->class = $storage;
$this->arguments = $arguments;
}
$this->mountPoint = $mountpoint;
}
/**
@ -113,7 +113,7 @@ class MountPoint implements IMountPoint {
if (class_exists($this->class)) {
try {
return $this->loader->getInstance($this->mountPoint, $this->class, $this->arguments);
return $this->loader->getInstance($this, $this->class, $this->arguments);
} catch (\Exception $exception) {
$this->invalidStorage = true;
if ($this->mountPoint === '/') {

View file

@ -8,6 +8,8 @@
namespace OC\Files\Storage;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IStorageFactory;
class StorageFactory implements IStorageFactory {
@ -55,23 +57,23 @@ class StorageFactory implements IStorageFactory {
/**
* Create an instance of a storage and apply the registered storage wrappers
*
* @param string|boolean $mountPoint
* @param \OCP\Files\Mount\IMountPoint $mountPoint
* @param string $class
* @param array $arguments
* @return \OCP\Files\Storage
*/
public function getInstance($mountPoint, $class, $arguments) {
public function getInstance(IMountPoint $mountPoint, $class, $arguments) {
return $this->wrap($mountPoint, new $class($arguments));
}
/**
* @param string|boolean $mountPoint
* @param \OCP\Files\Mount\IMountPoint $mountPoint
* @param \OCP\Files\Storage $storage
* @return \OCP\Files\Storage
*/
public function wrap($mountPoint, $storage) {
public function wrap(IMountPoint $mountPoint, $storage) {
foreach ($this->storageWrappers as $wrapper) {
$storage = $wrapper($mountPoint, $storage);
$storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint);
}
return $storage;
}

View file

@ -7,6 +7,7 @@
*/
namespace OCP\Files\Storage;
use OCP\Files\Mount\IMountPoint;
/**
* Creates storage instances and manages and applies storage wrappers
@ -25,10 +26,10 @@ interface IStorageFactory {
public function addStorageWrapper($wrapperName, $callback);
/**
* @param string|boolean $mountPoint
* @param \OCP\Files\Mount\IMountPoint $mountPoint
* @param string $class
* @param array $arguments
* @return \OCP\Files\Storage
*/
public function getInstance($mountPoint, $class, $arguments);
public function getInstance(IMountPoint $mountPoint, $class, $arguments);
}