* @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) {
*
* @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;
}
/**
*
* @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);