Skip to content

Commit

Permalink
Merge pull request #59 from jcord04/feature/local-file-system-bootstr…
Browse files Browse the repository at this point in the history
…ap-params

Feature/local file system bootstrap params
  • Loading branch information
schmunk42 authored Jul 31, 2023
2 parents 3222b27 + bf58bb9 commit 12b0c0c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 1.1.1

- Added argument overrides for Local filesystem adapter

## 1.1.0

- Fix Dropbox adapter not working

## 1.0.0-rc1
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ return [
'fs' => [
'class' => 'creocoder\flysystem\LocalFilesystem',
'path' => '@webroot/files',
// 'writeFlags' => LOCK_EX,
// 'linkHandling' => 0002,
// 'permissions' => [],
],
],
];
Expand Down
26 changes: 25 additions & 1 deletion src/LocalFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ class LocalFilesystem extends Filesystem
*/
public $path;

/**
* @var int
*/
public $writeFlags = LOCK_EX;

/**
* @var int
*/
public $linkHandling = Local::DISALLOW_LINKS;

/**
* @var array
*/
public $permissions = [];

/**
* @inheritdoc
*/
Expand All @@ -32,6 +47,14 @@ public function init()
throw new InvalidConfigException('The "path" property must be set.');
}

if (!in_array($this->writeFlags, [0, LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB], true)) {
throw new InvalidConfigException('The "writeFlags" property value is invalid.');
}

if ($this->linkHandling !== Local::DISALLOW_LINKS && $this->linkHandling !== Local::SKIP_LINKS) {
throw new InvalidConfigException('The "linkHandling" property value is invalid.');
}

$this->path = Yii::getAlias($this->path);

parent::init();
Expand All @@ -42,6 +65,7 @@ public function init()
*/
protected function prepareAdapter()
{
return new Local($this->path);
return new Local($this->path, $this->writeFlags, $this->linkHandling, $this->permissions);
}
}

0 comments on commit 12b0c0c

Please sign in to comment.