Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 6 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@
- [YamlWriterTask]
- File
- [FileMoverTask]
- [FileReaderTask]
- [FileReaderTask](reference/tasks/file_reader_task.md)
- [FileRemoverTask]
- [FileWriterTask]
- [FolderBrowserTask]
- [InputFolderBrowserTask]
- [FolderBrowserTask](reference/tasks/folder_browser_task.md)
- [InputFileReaderTask](reference/tasks/input_file_reader_task.md)
- [InputFolderBrowserTask](reference/tasks/input_folder_browser_task.md)
- [InputLineReaderTask](reference/tasks/input_line_reader_task.md)
- [LineReaderTask](reference/tasks/line_reader_task.md)
- Flow manipulation
- [AggregateIterableTask](reference/tasks/aggregate_iterable_task.md)
- [InputAggregatorTask](reference/tasks/input_aggregator_task.md)
Expand Down
40 changes: 40 additions & 0 deletions docs/reference/tasks/file_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FileReaderTask
=============

Reads a file and return raw content as a string

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

* **Service**: `CleverAge\ProcessBundle\Task\File\FileReaderTask`

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

Input is ignored

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

`string`: raw content of the file.
Underlying method is [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php).

Options
-------

| Code | Type | Required | Default | Description |
|------------|----------|:---------:|----------|------------------------------------------|
| `filename` | `string` | **X** | | Path of the file to read from (absolute) |

Example
-------

```yaml
# Task configuration level
code:
service: '@CleverAge\ProcessBundle\Task\File\FileReaderTask'
options:
filename: 'path/to/file.txt'
```


43 changes: 43 additions & 0 deletions docs/reference/tasks/folder_browser_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FolderBrowserTask
=============

Reads a folder and iterate on each file, returning absolute path as string.

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

* **Service**: `CleverAge\ProcessBundle\Task\File\FolderBrowserTask`
* **Iterable task**

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

Input is ignored

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

`string`: absolute path of the file.
Underlying method is [Symfony Finder component](https://symfony.com/doc/current/components/finder.html).

Options
-------

| Code | Type | Required | Default | Description |
|-------------------|-------------------------------|:---------:|---------------------------|------------------------------------|
| `folder_path` | `string` | **X** | | Path of the directory to read from |
| `name_pattern` | `null` or `string` or `array` | | null | Restrict files using a pattern |
| `empty_log_level` | `string` | | Psr\Log\LogLevel::WARNING | From Psr\Log\LogLevel constants |

Example
-------

```yaml
# Task configuration level
code:
service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
options:
folder_path: '%kernel.project_dir%/var/data'
```


41 changes: 41 additions & 0 deletions docs/reference/tasks/input_file_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
InputFileReaderTask
=============

Reads a file and return raw content as a string

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

* **Service**: `CleverAge\ProcessBundle\Task\File\InputFileReaderTask`

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

`string`: file path

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

`string`: raw content of the file.
Underlying method is [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php).

Options
-------

None

Example
-------

```yaml
# Task configuration level
entry:
service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
options:
folder_path: '%kernel.project_dir%/var/data'
outputs: read
read:
service: '@CleverAge\ProcessBundle\Task\File\InputFileReaderTask'
```


47 changes: 47 additions & 0 deletions docs/reference/tasks/input_folder_browser_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
InputFolderBrowserTask
=============

Reads a folder and iterate on each file, returning absolute path as string.

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

* **Service**: `CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask`
* **Iterable task**

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

`string`: folder path

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

`string`: absolute path of the file.
Underlying method is [Symfony Finder component](https://symfony.com/doc/current/components/finder.html).

Options
-------

| Code | Type | Required | Default | Description |
|--------------------|----------|:---------:|---------|---------------------------------------|
| `base_folder_path` | `string` | | | Concatenated with input `folder_path` |

Example
-------

```yaml
# Task configuration level
entry:
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
options:
output: '/var/data'
outputs: directory
directory:
service: '@CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask'
options:
base_folder_path: '%kernel.project_dir%'
outputs: read
```


42 changes: 42 additions & 0 deletions docs/reference/tasks/input_line_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
InputLineReaderTask
=============

Reads a file and iterate on each line, returning content as string. Skips empty lines.

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

* **Service**: `CleverAge\ProcessBundle\Task\File\InputLineReaderTask`
* **Iterable task**

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

`string`: file path

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

`string`: foreach line, it will return content as string.
Underlying method is [SplFileObject](https://www.php.net/manual/en/class.splfileobject.php).

Options
-------

None

Example
-------

```yaml
# Task configuration level
entry:
service: '@CleverAge\ProcessBundle\Task\File\FolderBrowserTask'
options:
folder_path: '%kernel.project_dir%/var/data'
outputs: read
read:
service: '@CleverAge\ProcessBundle\Task\File\InputLineReaderTask'
```


41 changes: 41 additions & 0 deletions docs/reference/tasks/line_reader_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
LineReaderTask
=============

Reads a file and iterate on each line, returning content as string. Skips empty lines.

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

* **Service**: `CleverAge\ProcessBundle\Task\File\LineReaderTask`
* **Iterable task**

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

Input is ignored

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

`string`: foreach line, it will return content as string.
Underlying method is [SplFileObject](https://www.php.net/manual/en/class.splfileobject.php).

Options
-------

| Code | Type | Required | Default | Description |
|------------|----------|:---------:|----------|------------------------------------------|
| `filename` | `string` | **X** | | Path of the file to read from (absolute) |

Example
-------

```yaml
# Task configuration level
code:
service: '@CleverAge\ProcessBundle\Task\File\LineReaderTask'
options:
filename: 'path/to/file.txt'
```


39 changes: 39 additions & 0 deletions src/Task/File/InputFileReaderTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/*
* This file is part of the CleverAge/ProcessBundle package.
*
* Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CleverAge\ProcessBundle\Task\File;

use CleverAge\ProcessBundle\Model\ProcessState;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Reads the whole input file and outputs its content.
*/
class InputFileReaderTask extends FileReaderTask
{
protected function getOptions(ProcessState $state): array
{
$options = parent::getOptions($state);
if (null !== $state->getInput()) {
$options['filename'] = $state->getInput();
}

return $options;
}

protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
$resolver->remove('filename');
}
}
39 changes: 39 additions & 0 deletions src/Task/File/InputLineReaderTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/*
* This file is part of the CleverAge/ProcessBundle package.
*
* Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CleverAge\ProcessBundle\Task\File;

use CleverAge\ProcessBundle\Model\ProcessState;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Reads an input file line by line and outputs each line.
*/
class InputLineReaderTask extends LineReaderTask
{
protected function getOptions(ProcessState $state): array
{
$options = parent::getOptions($state);
if (null !== $state->getInput()) {
$options['filename'] = $state->getInput();
}

return $options;
}

protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
$resolver->remove('filename');
}
}
Loading
Loading