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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Latest
------

### Changes
* [#51](https://github.com/cleverage/flysystem-process-bundle/issues/51) Give a code to the tasks ([cleverage/process-bundle#91](https://github.com/cleverage/process-bundle/issues/91)): `flysystem_file_fetch`, `flysystem_list_content` and `flysystem_remove_file` (`task: flysystem_file_fetch`, with `cleverage/process-bundle` 5.4 or later, referencing them by `service` being deprecated there). The tasks have their class name as service id; fetching them directly from the service container is deprecated (`container.private`), they will be private in 4.0. The former ids `cleverage_flysystem_process.task.file_fetch` / `cleverage_flysystem_process.task.list_content` / `cleverage_flysystem_process.task.remove_file` are deprecated aliases, removed in 4.0. Update documentation, add tests.
* [#49](https://github.com/cleverage/flysystem-process-bundle/issues/49) CI: test the lowest versions allowed by `composer.json` (`--prefer-lowest`, PHP 8.2). Require `psr/log` `^2|^3`: `cleverage/process-bundle` 5.x uses the typed `LoggerInterface` signatures (fatal error with `psr/log` 1).
* [#47](https://github.com/cleverage/flysystem-process-bundle/issues/47) Add a `.gitattributes`: the development files (`.docker/`, `.github/`, `tests/`, quality tools and PHPUnit configurations, `Makefile`) are no longer part of the archive installed by Composer (`dist`).
* [#45](https://github.com/cleverage/flysystem-process-bundle/issues/45) Require `league/flysystem` and `psr/log`, used directly by the tasks but only installed through `league/flysystem-bundle` and `cleverage/process-bundle`; add `league/flysystem-local` (used by the tests) to the dev requirements.
Expand Down
49 changes: 33 additions & 16 deletions config/services/task.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
services:
_defaults:
public: false
# Public for the direct access from the service container, deprecated since 3.3: private in 4.0
public: true
tags:
- { name: monolog.logger, channel: cleverage_process_task }
- { name: container.private, package: cleverage/flysystem-process-bundle, version: '3.3' }

cleverage_flysystem_process.task.file_fetch:
class: CleverAge\FlysystemProcessBundle\Task\FileFetchTask
CleverAge\FlysystemProcessBundle\Task\FileFetchTask:
shared: false
arguments: [!tagged_locator { tag: 'flysystem.storage', index_by: 'storage' }]
CleverAge\FlysystemProcessBundle\Task\FileFetchTask:
alias: cleverage_flysystem_process.task.file_fetch
public: true
tags:
- { name: cleverage.task, code: flysystem_file_fetch }
cleverage_flysystem_process.task.file_fetch:
alias: CleverAge\FlysystemProcessBundle\Task\FileFetchTask
public: false
deprecated:
package: cleverage/flysystem-process-bundle
version: '3.3'
message: 'The "%alias_id%" service alias is deprecated, use the "flysystem_file_fetch" task code or the class name of the task instead. It will be removed in 4.0.'

cleverage_flysystem_process.task.list_content:
class: CleverAge\FlysystemProcessBundle\Task\ListContentTask
CleverAge\FlysystemProcessBundle\Task\ListContentTask:
shared: false
arguments: [!tagged_locator { tag: 'flysystem.storage', index_by: 'storage' }]
CleverAge\FlysystemProcessBundle\Task\ListContentTask:
alias: cleverage_flysystem_process.task.list_content
public: true
tags:
- { name: cleverage.task, code: flysystem_list_content }
cleverage_flysystem_process.task.list_content:
alias: CleverAge\FlysystemProcessBundle\Task\ListContentTask
public: false
deprecated:
package: cleverage/flysystem-process-bundle
version: '3.3'
message: 'The "%alias_id%" service alias is deprecated, use the "flysystem_list_content" task code or the class name of the task instead. It will be removed in 4.0.'

cleverage_flysystem_process.task.remove_file:
class: CleverAge\FlysystemProcessBundle\Task\RemoveFileTask
CleverAge\FlysystemProcessBundle\Task\RemoveFileTask:
shared: false
arguments:
- '@logger'
- !tagged_locator { tag: 'flysystem.storage', index_by: 'storage' }
CleverAge\FlysystemProcessBundle\Task\RemoveFileTask:
alias: cleverage_flysystem_process.task.remove_file
public: true
tags:
- { name: cleverage.task, code: flysystem_remove_file }
cleverage_flysystem_process.task.remove_file:
alias: CleverAge\FlysystemProcessBundle\Task\RemoveFileTask
public: false
deprecated:
package: cleverage/flysystem-process-bundle
version: '3.3'
message: 'The "%alias_id%" service alias is deprecated, use the "flysystem_remove_file" task code or the class name of the task instead. It will be removed in 4.0.'
10 changes: 5 additions & 5 deletions docs/cookbooks/remote_cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ clever_age_process:
help: "bin/console cleverage:process:execute app.remote_cleanup -c year:2025"
tasks:
list:
service: '@CleverAge\FlysystemProcessBundle\Task\ListContentTask'
task: flysystem_list_content
options:
filesystem: 'remote.storage.archive'
file_pattern: '/^catalog_{{ year }}.*\.csv$/'
outputs: [only_files]

only_files:
service: '@CleverAge\ProcessBundle\Task\FilterTask'
task: filter
options:
match:
type: 'file'
outputs: [get_path]

get_path:
service: '@CleverAge\ProcessBundle\Task\PropertyGetterTask'
task: property_getter
options:
property: 'path'
outputs: [remove]

remove:
service: '@CleverAge\FlysystemProcessBundle\Task\RemoveFileTask'
task: flysystem_remove_file
options:
filesystem: 'remote.storage.archive'
```
Expand All @@ -59,7 +59,7 @@ clever_age_process:
app.remote_cleanup_pattern:
tasks:
remove:
service: '@CleverAge\FlysystemProcessBundle\Task\RemoveFileTask'
task: flysystem_remove_file
options:
filesystem: 'remote.storage.archive'
file_pattern: '/^catalog_{{ year }}.*\.csv$/'
Expand Down
10 changes: 5 additions & 5 deletions docs/cookbooks/sftp_export.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@ clever_age_process:
description: 'Export the catalog to the SFTP server'
tasks:
data:
service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask' # Replace with your own reader
task: constant_iterable_output # Replace with your own reader
options:
output:
- { sku: 'SKU-001', name: 'Product 1', price: '12.50' }
- { sku: 'SKU-002', name: 'Product 2', price: '8.90' }
outputs: [write]

write:
service: '@CleverAge\ProcessBundle\Task\File\Csv\CsvWriterTask'
task: csv_writer
options:
file_path: '%local.storage.dir%/catalog_{date_time}.csv'
headers: [sku, name, price]
outputs: [relative_path]

relative_path:
service: '@CleverAge\ProcessBundle\Task\TransformerTask'
task: transformer
options:
transformers:
callback:
callback: basename
outputs: [upload]

upload:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
task: flysystem_file_fetch
options:
source_filesystem: 'local.storage'
destination_filesystem: 'remote.storage.outgoing'
remove_source: true
outputs: [log_upload]

log_upload:
service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask'
task: logger
options:
level: info
message: 'File uploaded'
Expand Down
10 changes: 5 additions & 5 deletions docs/cookbooks/sftp_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,36 @@ clever_age_process:
description: 'Import the CSV files dropped on the SFTP server'
tasks:
fetch:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
task: flysystem_file_fetch
options:
source_filesystem: 'remote.storage.incoming'
destination_filesystem: 'local.storage'
file_pattern: '/\.csv$/'
outputs: [read, archive] # "archive" is executed once "read" has read the whole file

read:
service: '@CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask'
task: input_csv_reader
options:
base_path: '%local.storage.dir%'
delimiter: ';'
outputs: [import_line]

import_line:
service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask' # Replace with your own transformation and writer tasks
task: logger # Replace with your own transformation and writer tasks
options:
level: info
message: 'Imported line'

archive:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
task: flysystem_file_fetch
options:
source_filesystem: 'remote.storage.incoming'
destination_filesystem: 'remote.storage.archive'
remove_source: true
outputs: [cleanup_local]

cleanup_local:
service: '@CleverAge\FlysystemProcessBundle\Task\RemoveFileTask'
task: flysystem_remove_file
options:
filesystem: 'local.storage'
```
Expand Down
11 changes: 11 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ require their own package, e.g. `composer require league/flysystem-sftp-v3` for

## Configuration

The tasks of this bundle are registered as services (non-shared) and are used in your processes by their code,
`flysystem_file_fetch`, `flysystem_list_content` and `flysystem_remove_file` (e.g. `task: flysystem_file_fetch`, requires
`cleverage/process-bundle` 5.4 or later, see its [task definition](https://github.com/cleverage/process-bundle/blob/main/docs/reference/02-task_definition.md)).
Referencing them by their class name (`service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'`) is
deprecated since `cleverage/process-bundle` 5.4.

Their service id is their class name. Fetching them directly from the service container is deprecated since 3.3 (they
will be private in 4.0); their former ids, `cleverage_flysystem_process.task.file_fetch`,
`cleverage_flysystem_process.task.list_content` and `cleverage_flysystem_process.task.remove_file`, are deprecated
aliases since 3.3, removed in 4.0.

The tasks of this bundle work with the Flysystem **storages** configured in `config/packages/flysystem.yaml`: their
`filesystem`, `source_filesystem` and `destination_filesystem` options take the name of a storage (the key under
`flysystem.storages`). Configure at least one storage:
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/tasks/_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Task reference
--------------

* **Service**: `Fully\Qualified\ClassName`
* **Code**: `flysystem_task_code` (`task: flysystem_task_code`)
* **Iterable task** _(only if it implements `IterableTaskInterface`)_
* **Blocking task** _(only if it implements `BlockingTaskInterface`)_
* **Flushable task** _(only if it implements `FlushableTaskInterface`)_
Expand Down Expand Up @@ -39,7 +40,7 @@ Examples
```yaml
# Task configuration level
code:
service: '@Fully\Qualified\ClassName'
task: flysystem_task_code
options:
a: 1
b: 2
Expand Down
7 changes: 4 additions & 3 deletions docs/reference/tasks/file_fetch_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Task reference
--------------

* **Service**: `CleverAge\FlysystemProcessBundle\Task\FileFetchTask`
* **Code**: `flysystem_file_fetch` (`task: flysystem_file_fetch`)
* **Iterable task**

Accepted inputs
Expand Down Expand Up @@ -55,7 +56,7 @@ Examples
```yaml
# Task configuration level
fetch:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
task: flysystem_file_fetch
options:
source_filesystem: 'remote.storage'
destination_filesystem: 'local.storage'
Expand All @@ -74,7 +75,7 @@ my_process:
entry_point: copy_from_input
tasks:
copy_from_input:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
task: flysystem_file_fetch
options:
source_filesystem: '{{ source }}'
destination_filesystem: '{{ destination }}'
Expand All @@ -86,7 +87,7 @@ my_process:
```yaml
# Task configuration level
archive:
service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask'
task: flysystem_file_fetch
options:
source_filesystem: 'remote.storage.incoming'
destination_filesystem: 'remote.storage.archive'
Expand Down
9 changes: 5 additions & 4 deletions docs/reference/tasks/list_content_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Task reference
--------------

* **Service**: `CleverAge\FlysystemProcessBundle\Task\ListContentTask`
* **Code**: `flysystem_list_content` (`task: flysystem_list_content`)
* **Iterable task**

Accepted inputs
Expand Down Expand Up @@ -45,13 +46,13 @@ Examples
```yaml
# Task configuration level
list:
service: '@CleverAge\FlysystemProcessBundle\Task\ListContentTask'
task: flysystem_list_content
options:
filesystem: 'remote.storage'
file_pattern: '/\.csv$/'
outputs: [get_path]
get_path:
service: '@CleverAge\ProcessBundle\Task\PropertyGetterTask'
task: property_getter
options:
property: 'path'
outputs: [log]
Expand All @@ -63,12 +64,12 @@ get_path:
```yaml
# Task configuration level
list:
service: '@CleverAge\FlysystemProcessBundle\Task\ListContentTask'
task: flysystem_list_content
options:
filesystem: 'remote.storage'
outputs: [only_files]
only_files:
service: '@CleverAge\ProcessBundle\Task\FilterTask'
task: filter
options:
match:
type: 'file'
Expand Down
5 changes: 3 additions & 2 deletions docs/reference/tasks/remove_file_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Task reference
--------------

* **Service**: `CleverAge\FlysystemProcessBundle\Task\RemoveFileTask`
* **Code**: `flysystem_remove_file` (`task: flysystem_remove_file`)

Accepted inputs
---------------
Expand Down Expand Up @@ -42,7 +43,7 @@ my_process:
entry_point: remove_from_input
tasks:
remove_from_input:
service: '@CleverAge\FlysystemProcessBundle\Task\RemoveFileTask'
task: flysystem_remove_file
options:
filesystem: 'remote.storage'
```
Expand All @@ -52,7 +53,7 @@ my_process:
```yaml
# Task configuration level
purge:
service: '@CleverAge\FlysystemProcessBundle\Task\RemoveFileTask'
task: flysystem_remove_file
options:
filesystem: 'remote.storage'
file_pattern: '/\.csv$/'
Expand Down
Loading
Loading