Do not call wrapStorage if storate with same name added twice

This commit is contained in:
Vincent Petry 2015-01-21 22:27:59 +01:00
parent ff5715779c
commit 6fb553e92c
3 changed files with 12 additions and 1 deletions

View File

@ -175,7 +175,10 @@ class Filesystem {
* @param callable $wrapper
*/
public static function addStorageWrapper($wrapperName, $wrapper) {
self::getLoader()->addStorageWrapper($wrapperName, $wrapper);
if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper)) {
// do not re-wrap if storage with this name already existed
return;
}
$mounts = self::getMountManager()->getAll();
foreach ($mounts as $mount) {

View File

@ -23,9 +23,15 @@ class StorageFactory implements IStorageFactory {
*
* @param string $wrapperName
* @param callable $callback
* @return true if the wrapper was added, false if there was already a wrapper with this
* name registered
*/
public function addStorageWrapper($wrapperName, $callback) {
if (isset($this->storageWrappers[$wrapperName])) {
return false;
}
$this->storageWrappers[$wrapperName] = $callback;
return true;
}
/**

View File

@ -19,6 +19,8 @@ interface IStorageFactory {
*
* @param string $wrapperName
* @param callable $callback
* @return true if the wrapper was added, false if there was already a wrapper with this
* name registered
*/
public function addStorageWrapper($wrapperName, $callback);