const QUOTA_METRIC_GB = 4;
/**
- * Singleton instances.
- *
- * @var array
- */
- static protected $_instances = array();
-
- /**
* Hash containing connection parameters.
*
* @var array
protected $_vfsSize = null;
/**
- * Attempts to return a reference to a concrete instance based on
- * $driver. It will only create a new instance if no instance with the
- * same parameters currently exists.
- *
- * This should be used if multiple types of file backends (and, thus,
- * multiple VFS instances) are required.
- *
- * This method must be invoked as: $var = VFS::singleton();
- *
- * @param mixed $driver The type of concrete subclass to return. This
- * is based on the storage driver ($driver). The
- * code is dynamically included.
- * @param array $params A hash containing any additional configuration or
- * connection parameters a subclass might need.
- *
- * @return VFS The concrete VFS reference.
- * @throws VFS_Exception
- */
- static public function singleton($driver, $params = array())
- {
- ksort($params);
- $signature = serialize(array($driver, $params));
- if (!isset(self::$_instances[$signature])) {
- self::$_instances[$signature] = self::factory($driver, $params);
- }
-
- return self::$_instances[$signature];
- }
-
- /**
* Attempts to return a concrete instance based on $driver.
*
* @param mixed $driver The type of concrete subclass to return. This
*/
static public function factory($driver, $params = array())
{
- $driver = basename($driver);
+ $driver = basename(ucfirst($driver));
$class = __CLASS__ . '_' . $driver;
- if (!class_exists($class)) {
- include_once 'VFS/' . $driver . '.php';
- if (!class_exists($class)) {
- throw new VFS_Exception('Class definition of ' . $class . ' not found.');
- }
+
+ if (class_exists($class)) {
+ return new $class($params);
}
- return new $class($params);
+ throw new VFS_Exception('Class definition of ' . $class . ' not found.');
}
/**
protected $_folderList;
/**
- * Attempts to return a reference to a concrete instance
- * based on $driver. It will only create a new instance if no
- * VFS instance with the same parameters currently exists.
- *
- * This should be used if multiple types of file backends (and,
- * thus, multiple VFS instances) are required.
- *
- * This method must be invoked as: $var = VFS_Object::singleton();
- *
- * @param mixed $driver The type of concrete subclass to return.
- * @param array $params A hash containing any additional configuration or
- * connection parameters a subclass might need.
- *
- * @return VFS_Object The concrete VFS_Object reference.
- * @throws VFS_Exception
- */
- static public function singleton($driver, $params = array())
- {
- require_once dirname(__FILE__) . '/../VFS.php';
- $classname = __CLASS__;
- return new $classname(VFS::singleton($driver, $params = array()));
- }
-
- /**
- * Attempts to return a concrete instance based on $driver.
- *
- * @param mixed $driver The type of concrete subclass to return.
- * @param array $params A hash containing any additional configuration or
- * connection parameters a subclass might need.
- *
- * @return VFS_Object The newly created concrete VFS_Object instance.
- * @throws VFS_Exception
- */
- static public function factory($driver, $params = array())
- {
- return self::singleton($driver, $params);
- }
-
- /**
* Constructor.
*
* If you pass in an existing VFS object, it will be used as the VFS
$this->_folderList = $folderList;
$this->_currentPath = $path;
} else {
- require_once dirname(__FILE__) . '/Exception.php';
throw new VFS_Exception('Could not read ' . $path . '.');
}
}
- require_once dirname(__FILE__) . '/ListItem.php';
return ($file = array_shift($this->_folderList))
? new VFS_ListItem($path, $file)
: false;
// TODO: Shortcut with VFS::copy()
}
- $source_vfs = &vfs($source_params);
- $target_vfs = &vfs($target_params);
+ $source_vfs = vfs($source_params);
+ $target_vfs = vfs($target_params);
_cp($source_vfs, $target_vfs, $source_path, $target_path, $argv, $filter);
}
*/
function vfs($params)
{
- return VFS::singleton($params['driver'], $params);
+ return VFS::factory($params['driver'], $params);
}
/**