Skip to content

Commit 12b0c0c

Browse files
authored
Merge pull request #59 from jcord04/feature/local-file-system-bootstrap-params
Feature/local file system bootstrap params
2 parents 3222b27 + bf58bb9 commit 12b0c0c

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 1.1.1
4+
5+
- Added argument overrides for Local filesystem adapter
6+
7+
## 1.1.0
8+
39
- Fix Dropbox adapter not working
410

511
## 1.0.0-rc1

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ return [
3939
'fs' => [
4040
'class' => 'creocoder\flysystem\LocalFilesystem',
4141
'path' => '@webroot/files',
42+
// 'writeFlags' => LOCK_EX,
43+
// 'linkHandling' => 0002,
44+
// 'permissions' => [],
4245
],
4346
],
4447
];

src/LocalFilesystem.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ class LocalFilesystem extends Filesystem
2323
*/
2424
public $path;
2525

26+
/**
27+
* @var int
28+
*/
29+
public $writeFlags = LOCK_EX;
30+
31+
/**
32+
* @var int
33+
*/
34+
public $linkHandling = Local::DISALLOW_LINKS;
35+
36+
/**
37+
* @var array
38+
*/
39+
public $permissions = [];
40+
2641
/**
2742
* @inheritdoc
2843
*/
@@ -32,6 +47,14 @@ public function init()
3247
throw new InvalidConfigException('The "path" property must be set.');
3348
}
3449

50+
if (!in_array($this->writeFlags, [0, LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB], true)) {
51+
throw new InvalidConfigException('The "writeFlags" property value is invalid.');
52+
}
53+
54+
if ($this->linkHandling !== Local::DISALLOW_LINKS && $this->linkHandling !== Local::SKIP_LINKS) {
55+
throw new InvalidConfigException('The "linkHandling" property value is invalid.');
56+
}
57+
3558
$this->path = Yii::getAlias($this->path);
3659

3760
parent::init();
@@ -42,6 +65,7 @@ public function init()
4265
*/
4366
protected function prepareAdapter()
4467
{
45-
return new Local($this->path);
68+
return new Local($this->path, $this->writeFlags, $this->linkHandling, $this->permissions);
4669
}
4770
}
71+

0 commit comments

Comments
 (0)