File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @link https://github.com/creocoder/yii2-flysystem
4+ * @copyright Copyright (c) 2015 Alexander Kochetov
5+ * @license http://opensource.org/licenses/BSD-3-Clause
6+ */
7+
8+ namespace creocoder \flysystem ;
9+
10+ use League \Flysystem \GridFS \GridFSAdapter ;
11+ use MongoClient ;
12+ use Yii ;
13+ use yii \base \InvalidConfigException ;
14+
15+ /**
16+ * GridFSFilesystem
17+ *
18+ * @author Alexander Kochetov <[email protected] > 19+ */
20+ class GridFSFilesystem extends Filesystem
21+ {
22+ /**
23+ * @var string
24+ */
25+ public $ server ;
26+ /**
27+ * @var string
28+ */
29+ public $ database ;
30+
31+ /**
32+ * @inheritdoc
33+ */
34+ public function init ()
35+ {
36+ if ($ this ->server === null ) {
37+ throw new InvalidConfigException ('The "server" property must be set. ' );
38+ }
39+
40+ if ($ this ->database === null ) {
41+ throw new InvalidConfigException ('The "database" property must be set. ' );
42+ }
43+
44+ parent ::init ();
45+ }
46+
47+ /**
48+ * @return GridFSAdapter
49+ */
50+ protected function prepareAdapter ()
51+ {
52+ return new GridFSAdapter ((new MongoClient ($ this ->server ))->selectDB ($ this ->database )->getGridFS ());
53+ }
54+ }
You can’t perform that action at this time.
0 commit comments