3 * @defgroup ExternalStorage ExternalStorage
7 * @ingroup ExternalStorage
9 class ExternalStoreFactory
{
14 private $externalStores;
17 * @param array $externalStores See $wgExternalStores
19 public function __construct( array $externalStores ) {
20 $this->externalStores
= array_map( 'strtolower', $externalStores );
24 * Get an external store object of the given type, with the given parameters
26 * @param string $proto Type of external storage, should be a value in $wgExternalStores
27 * @param array $params Associative array of ExternalStoreMedium parameters
28 * @return ExternalStoreMedium|bool The store class or false on error
30 public function getStoreObject( $proto, array $params = [] ) {
31 if ( !$this->externalStores ||
!in_array( strtolower( $proto ), $this->externalStores
) ) {
32 // Protocol not enabled
36 $class = 'ExternalStore' . ucfirst( $proto );
38 // Any custom modules should be added to $wgAutoLoadClasses for on-demand loading
39 return class_exists( $class ) ?
new $class( $params ) : false;