@@ 23-49 (lines=27) @@ | ||
20 | * @package MW |
|
21 | * @subpackage Filesystem |
|
22 | */ |
|
23 | class FlyGridfs extends FlyBase implements Iface, DirIface, MetaIface |
|
24 | { |
|
25 | private $fs; |
|
26 | ||
27 | ||
28 | /** |
|
29 | * Returns the file system provider |
|
30 | * |
|
31 | * @return \League\Flysystem\FilesystemInterface File system provider |
|
32 | */ |
|
33 | protected function getProvider() |
|
34 | { |
|
35 | if( !isset( $this->fs ) ) |
|
36 | { |
|
37 | $config = $this->getConfig(); |
|
38 | ||
39 | if( !isset( $config['dbname'] ) ) { |
|
40 | throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'dbname' ) ); |
|
41 | } |
|
42 | ||
43 | $client = new \MongoClient(); |
|
44 | $this->fs = new Filesystem( new GridFSAdapter( $client->selectDB( $config['dbname'] )->getGridFS() ) ); |
|
45 | } |
|
46 | ||
47 | return $this->fs; |
|
48 | } |
|
49 | } |
|
50 |
@@ 23-49 (lines=27) @@ | ||
20 | * @package MW |
|
21 | * @subpackage Filesystem |
|
22 | */ |
|
23 | class FlyLocal extends FlyBase implements Iface, DirIface, MetaIface |
|
24 | { |
|
25 | private $fs; |
|
26 | ||
27 | ||
28 | /** |
|
29 | * Returns the file system provider |
|
30 | * |
|
31 | * @return \League\Flysystem\FilesystemInterface File system provider |
|
32 | */ |
|
33 | protected function getProvider() |
|
34 | { |
|
35 | if( !isset( $this->fs ) ) |
|
36 | { |
|
37 | $config = $this->getConfig(); |
|
38 | ||
39 | if( !isset( $config['basedir'] ) ) { |
|
40 | throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'basedir' ) ); |
|
41 | } |
|
42 | ||
43 | $adapter = new Local( $config['basedir'], LOCK_EX, Local::SKIP_LINKS, $config ); |
|
44 | $this->fs = new Filesystem( $adapter ); |
|
45 | } |
|
46 | ||
47 | return $this->fs; |
|
48 | } |
|
49 | } |
|
50 |