| @@ 19-47 (lines=29) @@ | ||
| 16 | * |
|
| 17 | * @author Alexander Kochetov <[email protected]> |
|
| 18 | */ |
|
| 19 | class LocalFilesystem extends Filesystem |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | public $path; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @inheritdoc |
|
| 28 | */ |
|
| 29 | public function init() |
|
| 30 | { |
|
| 31 | if ($this->path === null) { |
|
| 32 | throw new InvalidConfigException('The "path" property must be set.'); |
|
| 33 | } |
|
| 34 | ||
| 35 | $this->path = Yii::getAlias($this->path); |
|
| 36 | ||
| 37 | parent::init(); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @return Local |
|
| 42 | */ |
|
| 43 | protected function prepareAdapter() |
|
| 44 | { |
|
| 45 | return new Local($this->path); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 19-55 (lines=37) @@ | ||
| 16 | * |
|
| 17 | * @author Alexander Kochetov <[email protected]> |
|
| 18 | */ |
|
| 19 | class ZipArchiveFilesystem extends Filesystem |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | public $path; |
|
| 25 | /** |
|
| 26 | * @var string|null |
|
| 27 | */ |
|
| 28 | public $prefix; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @inheritdoc |
|
| 32 | */ |
|
| 33 | public function init() |
|
| 34 | { |
|
| 35 | if ($this->path === null) { |
|
| 36 | throw new InvalidConfigException('The "path" property must be set.'); |
|
| 37 | } |
|
| 38 | ||
| 39 | $this->path = Yii::getAlias($this->path); |
|
| 40 | ||
| 41 | parent::init(); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return ZipArchiveAdapter |
|
| 46 | */ |
|
| 47 | protected function prepareAdapter() |
|
| 48 | { |
|
| 49 | return new ZipArchiveAdapter( |
|
| 50 | $this->path, |
|
| 51 | null, |
|
| 52 | $this->prefix |
|
| 53 | ); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||