-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVolume.php
60 lines (43 loc) · 1.49 KB
/
Volume.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Date: 10.05.2016
* Time: 18:29
*/
namespace mihaildev\elfinder\flysystem;
use League\Flysystem\Filesystem;
use mihaildev\elfinder\volume\Base;
use yii\base\InvalidConfigException;
class Volume extends Base
{
public $driver = 'Flysystem';
public $separator = "/";
public $path = "/";
public $url;
public $component;
public $glideURL;
public $glideKey;
protected function optionsModifier($options){
if(empty($this->component))
throw new InvalidConfigException('The "component" property must be set.');
/** @var Filesystem $component */
if(is_string($this->component)){
$component = \Yii::$app->get($this->component);
}else{
$component = \Yii::createObject($this->component);
}
if(!($component instanceof \creocoder\flysystem\Filesystem || $component instanceof Filesystem))
throw new InvalidConfigException('A Filesystem instance is required');
$options['separator'] = $this->separator;
$options['filesystem'] = new Filesystem($component->getAdapter());
$options['path'] = $this->path;
if(!empty($this->glideURL) && !empty($this->glideKey)){
$options['glideURL'] = $this->glideURL;
$options['glideKey'] = $this->glideKey;
unset($options['tmbPath']);
unset($options['tmbURL']);
}
if(!empty($this->url))
$options['URL'] = $this->url;
return $options;
}
}