Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@ Remember to add the following line to config/bundles.php (not required if Symfon
CleverAge\FlysystemProcessBundle\CleverAgeFlysystemProcessBundle::class => ['all' => true],
```

Configure at least one flysytem/storage into `config/packages/flysytem.yaml`

```yaml
#config/packages/flysytem.yaml
flysystem:
storages:
storage.source: # This is the identifier of flysytem/storage
adapter: 'local'
options:
directory: '%kernel.project_dir%/var/storage/source'
```

See https://github.com/thephpleague/flysystem-bundle?tab=readme-ov-file for more sample configuration (sftp, ftp, amazon s3 ...)


## Reference

- Tasks
- [FileFetchTask]
- [ListContentTask]
- [RemoveFileTask]
- [FileFetchTask](reference/tasks/01-FileFetchTask.md)
- [ListContentTask](reference/tasks/02-ListContentTask.md)
- [RemoveFileTask](reference/tasks/03-RemoveFileTask.md)
73 changes: 73 additions & 0 deletions docs/reference/tasks/01-FileFetchTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
FileFetchTask
========

Perform copy between 2 flysystems storage

Task reference
--------------

* **Service**: [`CleverAge\FlysystemProcessBundle\Task\FileFetchTask`](../src/Task/FileFetchTask.php)

Accepted inputs
---------------

The filename or filenames to copy from.

If the option `file_pattern` is not set the input is used as strict filename(s) to match.

If input is set but not corresponding as any file into `source_filesystem` task failed with UnableToReadFile exception.

If FileFetchTask is the fisrt task of you process and you wan to use input, don't forgive to set the `entry_point` task name at process level

Possible outputs
----------------

Filename of copied file.

Options
-------

| Code | Type | Required | Default | Description |
|--------------------------|:----------:|:---------:|:---------:|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `source_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
| `destination_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
| `file_pattern` | `string` | | null | The file_parttern used in preg_match to match into `source_filesystem` list of files. If not set try to use input as strict filename to match |
| `remove_source` | `bool` | | false | If true delete source file after copy |


Examples
--------

* Simple fetch task configuration
- See config/packages/flysystem.yaml to see configured flysystems/storages.
- copy all .csv files from 'storage.source' to 'storage.destination'
- remove .csv from 'storage.source' after copy
- output will be filename of copied files
```yaml
# Task configuration level
code:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
options:
source_filesystem: 'storage.source'
destination_filesystem: 'storage.destination'
file_pattern: '/.csv$/'
remove_source: true
```

* Simple fetch process configuration to cipy a specific file from --input option via <br> ```bin/console cleverage:process:execute my_custom_process --input=foobar.csv -vv```
- See config/packages/flysystem.yaml to see configured flysystems/storages.
- copy input file from 'storage.source' to 'storage.destination'
- remove .csv from 'storage.source' after copy
- output will be filename of copied file
```yaml
# Full process configuration to use input as filename with the following call
my_custom_process:
entry_point: copy_from_input
tasks:
copy_from_input:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
options:
source_filesystem: 'storage.source'
destination_filesystem: 'storage.destination'
remove_source: true
```
42 changes: 42 additions & 0 deletions docs/reference/tasks/02-ListContentTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ListContentTask
========

List files of a flysystem storage

Task reference
--------------

* **Service**: [`CleverAge\FlysystemProcessBundle\Task\ListContentTask`](../src/Task/ListContentTask.php)

Accepted inputs
---------------

Input is ignored

Possible outputs
----------------

League\Flysystem\StorageAttributes

Options
-------

| Code | Type | Required | Default | Description |
|----------------|:----------:|:---------:|:---------:|------------------------------------------------------------------------------------------------------------|
| `filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |
| `file_pattern` | `string` | | | The file_parttern used in preg_match to match into `filesystem` |

Examples
--------
* Simple list task configuration from a filesystem
- see config/packages/flysystem.yaml to see configured flysystems/storages.
- list all .csv files from 'storage.source'
- output will be League\Flysystem\StorageAttributes representation of copied files
```yaml
# Task configuration level
code:
service: '@CleverAge\FlysystemProcessBundle\Task\ListContentTask'
options:
filesystem: 'storage.source'
file_pattern: '/.csv$/'
```
46 changes: 46 additions & 0 deletions docs/reference/tasks/03-RemoveFileTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
RemoveFileTask
========

Remove a file from a flysystem storage

Task reference
--------------

* **Service**: [`CleverAge\FlysystemProcessBundle\Task\RemoveFileTask`](../src/Task/RemoveFileTask.php)

Accepted inputs
---------------

The filename of the file to remove on `filesystem`.

When filename is deleted add a info log.

If filename not found or cannot be deleted on `filesystem` add a warning log.

Possible outputs
----------------

None

Options
-------

| Code | Type | Required | Default | Description |
|--------------|:----------:|:----------:|:---------:|-------------------------------------------------------------------------------------------------------------|
| `filesystem` | `string` | **X** | | The source flysystem/storage. <br/>See config/packages/flysystem.yaml to see configured flysystem/storages. |

Examples
--------
* Simple process to remove a file on 'storage.source' via <br>```bin/console cleverage:process:execute my_custom_process --input=foobar.csv -vv```
- see config/packages/flysystem.yaml to see configured flysystems/storages.
- remove file with name passed as input
```yaml
#
my_custom_process:
entry_point: remove_from_input
tasks:
remove_from_input:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
options:
filesystem: 'storage.source'
```
Loading