* @since 1.19
*/
class FileBackendGroup {
- /**
- * @var FileBackendGroup
- */
+ /** @var FileBackendGroup */
protected static $instance = null;
- /** @var Array (name => ('class' => string, 'config' => array, 'instance' => object)) */
+ /** @var array (name => ('class' => string, 'config' => array, 'instance' => object)) */
protected $backends = array();
- protected function __construct() {}
+ protected function __construct() {
+ }
/**
* @return FileBackendGroup
self::$instance = new self();
self::$instance->initFromGlobals();
}
+
return self::$instance;
}
/**
* Destroy the singleton instance
- *
- * @return void
*/
public static function destroySingleton() {
self::$instance = null;
/**
* Register file backends from the global variables
- *
- * @return void
*/
protected function initFromGlobals() {
global $wgLocalFileRepo, $wgForeignFileRepos, $wgFileBackends;
/**
* Register an array of file backend configurations
*
- * @param $configs Array
- * @return void
+ * @param array $configs
* @throws MWException
*/
protected function register( array $configs ) {
/**
* Get the backend object with a given name
*
- * @param $name string
+ * @param string $name
* @return FileBackend
* @throws MWException
*/
$config = $this->backends[$name]['config'];
$this->backends[$name]['instance'] = new $class( $config );
}
+
return $this->backends[$name]['instance'];
}
/**
* Get the config array for a backend object with a given name
*
- * @param $name string
- * @return Array
+ * @param string $name
+ * @return array
* @throws MWException
*/
public function config( $name ) {
throw new MWException( "No backend defined with the name `$name`." );
}
$class = $this->backends[$name]['class'];
+
return array( 'class' => $class ) + $this->backends[$name]['config'];
}
/**
* Get an appropriate backend object from a storage path
*
- * @param $storagePath string
+ * @param string $storagePath
* @return FileBackend|null Backend or null on failure
*/
public function backendFromPath( $storagePath ) {
if ( $backend !== null && isset( $this->backends[$backend] ) ) {
return $this->get( $backend );
}
+
return null;
}
}