From debeec069013a8ea873f1178b6cf013cf2372caf Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Thu, 12 Dec 2024 09:43:44 +0100 Subject: [PATCH] #145 Add/Update docs --- docs/index.md | 8 +- .../tasks/constant_iterable_output_task.md | 24 +-- docs/reference/tasks/constant_output_task.md | 24 +-- docs/reference/tasks/counter_task.md | 31 +--- docs/reference/tasks/csv_reader_task.md | 32 +++- docs/reference/tasks/debug_task.md | 29 ++-- docs/reference/tasks/die_task.md | 16 +- docs/reference/tasks/dummy_task.md | 50 +++--- docs/reference/tasks/error_forwarder_task.md | 25 +-- docs/reference/tasks/event_dispatcher_task.md | 18 +- docs/reference/tasks/input_csv_reader_task.md | 46 +++++ docs/reference/tasks/logger_task.md | 41 +++++ docs/reference/tasks/stopwatch_task.md | 21 ++- docs/reference/tasks/transformer_task.md | 17 +- .../transformers/implode_transformer.md | 38 +++++ .../transformers/mapping_transformer.md | 157 ++++++++---------- .../transformers/rules_transformer.md | 64 +++---- .../transformers/slugify_transformer.md | 39 +++++ 18 files changed, 410 insertions(+), 270 deletions(-) create mode 100644 docs/reference/tasks/input_csv_reader_task.md create mode 100644 docs/reference/tasks/logger_task.md create mode 100644 docs/reference/transformers/implode_transformer.md create mode 100644 docs/reference/transformers/slugify_transformer.md diff --git a/docs/index.md b/docs/index.md index 6e1a4a42..96f54c07 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,7 +44,7 @@ - [CsvReaderTask](reference/tasks/csv_reader_task.md) - [CsvWriterTask](reference/tasks/csv_writer_task.md) - [CSVSplitterTask] - - [InputCsvReaderTask] + - [InputCsvReaderTask](reference/tasks/input_csv_reader_task.md) - File/JsonStream - [JsonStreamReaderTask] - File/XML @@ -79,7 +79,7 @@ - [ProcessLauncherTask] - Reporting - [AdvancedStatCounterTask] - - [LoggerTask] + - [LoggerTask](reference/tasks/logger_task.md) - [StatCounterTask] - Transformers - Basic and debug @@ -120,8 +120,8 @@ - String - [ExplodeTransformer] - [HashTransformer] - - [ImplodeTransformer] - - [SlugifyTransformer] + - [ImplodeTransformer](reference/transformers/implode_transformer.md) + - [SlugifyTransformer](reference/transformers/slugify_transformer.md) - [SprintfTransformer] - [TrimTransformer](reference/transformers/trim_transformer.md) - XML diff --git a/docs/reference/tasks/constant_iterable_output_task.md b/docs/reference/tasks/constant_iterable_output_task.md index ba3f6410..30b04829 100644 --- a/docs/reference/tasks/constant_iterable_output_task.md +++ b/docs/reference/tasks/constant_iterable_output_task.md @@ -29,18 +29,12 @@ Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.constant_iterable_output_example: - tasks: - constant_iterable_output_example: - service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask' - options: - output: - id: 123 - firstname: Test1 - lastname: Test2 - outputs: [debug] - debug: - service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask' + options: + output: + id: 123 + firstname: Test1 + lastname: Test2 +``` diff --git a/docs/reference/tasks/constant_output_task.md b/docs/reference/tasks/constant_output_task.md index 03fd41c3..ed2f042f 100644 --- a/docs/reference/tasks/constant_output_task.md +++ b/docs/reference/tasks/constant_output_task.md @@ -29,18 +29,12 @@ Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.constant_output_example: - tasks: - constant_output_example: - service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' - options: - output: - id: 123 - firstname: Test1 - lastname: Test2 - outputs: [debug] - debug: - service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' + options: + output: + id: 123 + firstname: Test1 + lastname: Test2 +``` diff --git a/docs/reference/tasks/counter_task.md b/docs/reference/tasks/counter_task.md index 997c8af7..455539e4 100644 --- a/docs/reference/tasks/counter_task.md +++ b/docs/reference/tasks/counter_task.md @@ -13,7 +13,7 @@ Task reference Accepted inputs --------------- -`any` +`any`, must implement IterableTaskInterface Possible outputs ---------------- @@ -31,26 +31,9 @@ Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.counter_example: - tasks: - counter_example: - service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask' - options: - output: - test1: test1 - test2: test2 - test3: test3 - test4: test4 - test5: test5 - test6: test6 - outputs: [counter] - counter: - service: '@CleverAge\ProcessBundle\Task\CounterTask' - options: - flush_every: 2 - outputs: [ debug ] - debug: - service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\CounterTask' + options: + flush_every: 2 +``` diff --git a/docs/reference/tasks/csv_reader_task.md b/docs/reference/tasks/csv_reader_task.md index b5df5a40..0e7b4c3a 100644 --- a/docs/reference/tasks/csv_reader_task.md +++ b/docs/reference/tasks/csv_reader_task.md @@ -23,12 +23,26 @@ Underlying method is [fgetcsv](https://secure.php.net/manual/en/function.fgetcsv Options ------- -| Code | Type | Required | Default | Description | -| ---- | ---- | :------: | ------- | ----------- | -| `file_path` | `string` | **X** | | Path of the file to read from (relative to symfony root or absolute) | -| `delimiter` | `string` | | `;` | CSV delimiter | -| `enclosure` | `string` | | `"` | CSV enclosure character | -| `escape` | `string` | | `\\` | CSV escape character | -| `headers` | `array` or `null` | | `null` | Static list of CSV headers, without the option, it will be dynamically read from first input | -| `mode` | `string` | | `rb` | File open mode (see [fopen mode parameter](https://secure.php.net/manual/en/function.fopen.php)) | -| `log_empty_lines` | `bool` | | `false` | Log when the output is empty | +| Code | Type | Required | Default | Description | +|-------------------|-------------------|:---------:|----------|--------------------------------------------------------------------------------------------------| +| `file_path` | `string` | **X** | | Path of the file to read from (relative to symfony root or absolute) | +| `delimiter` | `string` | | `;` | CSV delimiter | +| `enclosure` | `string` | | `"` | CSV enclosure character | +| `escape` | `string` | | `\\` | CSV escape character | +| `headers` | `array` or `null` | | `null` | Static list of CSV headers, without the option, it will be dynamically read from first input | +| `mode` | `string` | | `rb` | File open mode (see [fopen mode parameter](https://secure.php.net/manual/en/function.fopen.php)) | +| `log_empty_lines` | `bool` | | `false` | Log when the output is empty | + +Example +------- + +```yaml +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\File\Csv\CsvReaderTask' + options: + file_path: 'path/to/file.csv' + delimiter: '{{ delimiter }}' ## delimiter is contextualized you must add -c delimiter:";" on console execute +``` + + diff --git a/docs/reference/tasks/debug_task.md b/docs/reference/tasks/debug_task.md index 5a654089..cfaf44d7 100644 --- a/docs/reference/tasks/debug_task.md +++ b/docs/reference/tasks/debug_task.md @@ -20,22 +20,21 @@ Possible outputs `any`: re-output given input +Options +------- + +None + Example ---------------- ```yaml -clever_age_process: - configurations: - project_prefix.debug_example: - tasks: - debug_example: - service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' - options: - output: - id: 123 - firstname: Test1 - lastname: Test2 - outputs: [debug] - debug: - service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' + options: + output: + id: 123 + firstname: Test1 + lastname: Test2 +``` diff --git a/docs/reference/tasks/die_task.md b/docs/reference/tasks/die_task.md index 24008f4d..741fdeed 100644 --- a/docs/reference/tasks/die_task.md +++ b/docs/reference/tasks/die_task.md @@ -19,14 +19,16 @@ Possible outputs None +Options +------- + +None + Example ---------------- ```yaml -clever_age_process: - configurations: - project_prefix.die_example: - tasks: - die_example: - service: '@CleverAge\ProcessBundle\Task\Debug\DieTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\Debug\DieTask' +``` diff --git a/docs/reference/tasks/dummy_task.md b/docs/reference/tasks/dummy_task.md index 87fda52e..323cafc5 100644 --- a/docs/reference/tasks/dummy_task.md +++ b/docs/reference/tasks/dummy_task.md @@ -18,33 +18,31 @@ Possible outputs `any`: re-output given input +Options +------- + +None + Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.dummy_example: - tasks: - dummy_example: - service: '@CleverAge\ProcessBundle\Task\DummyTask' - outputs: [output1, output2] - output1: - service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' - options: - output: - id: 123 - firstname: Test1 - lastname: Test2 - outputs: [debug] - output2: - service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' - options: - output: - id: 456 - firstname: Test3 - lastname: Test4 - outputs: [ debug ] - debug: - service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask' -``` \ No newline at end of file +# Task configuration level +dummy: + service: '@CleverAge\ProcessBundle\Task\DummyTask' + outputs: [output1, output2] +output1: + service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' + options: + output: + id: 123 + firstname: Test1 + lastname: Test2 +output2: + service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask' + options: + output: + id: 456 + firstname: Test3 + lastname: Test4 +``` diff --git a/docs/reference/tasks/error_forwarder_task.md b/docs/reference/tasks/error_forwarder_task.md index df129aa3..592c9cb2 100644 --- a/docs/reference/tasks/error_forwarder_task.md +++ b/docs/reference/tasks/error_forwarder_task.md @@ -20,23 +20,16 @@ Possible outputs `any`: directly error_output given `output` option +Options +------- + +None + Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.error_forwarder_example: - tasks: - error_forwarder_example: - service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask' - options: - output: - error1: Error 1 - error2: Error 2 - error3: Error 3 - outputs: [error_forwarder] - error_forwarder: - service: '@CleverAge\ProcessBundle\Task\Debug\ErrorForwarderTask' - -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\Debug\ErrorForwarderTask' +``` diff --git a/docs/reference/tasks/event_dispatcher_task.md b/docs/reference/tasks/event_dispatcher_task.md index 1a2d17b7..88c87e98 100644 --- a/docs/reference/tasks/event_dispatcher_task.md +++ b/docs/reference/tasks/event_dispatcher_task.md @@ -31,15 +31,9 @@ Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.event_dispatcher_example: - tasks: - event_dispatcher_example: - service: '@CleverAge\ProcessBundle\Task\Event\EventDispatcherTask' - options: - event_name: 'myapp.myevent' - outputs: [debug] - debug: - service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\Event\EventDispatcherTask' + options: + event_name: 'myapp.myevent' +``` diff --git a/docs/reference/tasks/input_csv_reader_task.md b/docs/reference/tasks/input_csv_reader_task.md new file mode 100644 index 00000000..59e67d2a --- /dev/null +++ b/docs/reference/tasks/input_csv_reader_task.md @@ -0,0 +1,46 @@ +InputCsvReaderTask +============= + +Reads a CSV file and iterate on each line, returning an array of key -> values. Skips empty lines. + +Task reference +-------------- + +* **Service**: `CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask` +* **Iterable task** + +Accepted inputs +--------------- + +`string`: file path + +Possible outputs +---------------- + +`array`: foreach line, it will return a php array where key comes from headers and values are strings. +Underlying method is [fgetcsv](https://secure.php.net/manual/en/function.fgetcsv.php). + +Options +------- + +Same as [CsvReaderTask](reference/tasks/csv_reader_task.md) except following : + +| Code | Type | Required | Default | Description | +|-------------|----------|:--------:|---------|----------------------------| +| `file_path` | | | | Removed, use input instead | +| `base_path` | `string` | | `` | | + +Example +------- + +```yaml +clever_age_process: + configurations: + process.name: + entry_point: entrypoint # for upload_and_run process entry_point is required + tasks: + entrypoint: + service: '@CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask' + options: + delimiter: '{{ delimiter }}' ## delimiter is contextualized you must add -c delimiter:";" on console execute +``` diff --git a/docs/reference/tasks/logger_task.md b/docs/reference/tasks/logger_task.md new file mode 100644 index 00000000..ffcc51ac --- /dev/null +++ b/docs/reference/tasks/logger_task.md @@ -0,0 +1,41 @@ +LoggerTask +============= + +Log a specific message with context. + +Task reference +-------------- + +* **Service**: `CleverAge\ProcessBundle\Task\Reporting\LoggerTask` + +Accepted inputs +--------------- + +`any` + +Possible outputs +---------------- + +`any` : forwarded input + +Options +------- + +| Code | Type | Required | Default | Description | +|-------------|--------------------|:---------:|-------------------|---------------------------------| +| `level` | `string` | **X** | `debug` | Use `Psr\Log\LogLevel` values | +| `message` | `string` | | `Log state input` | | +| `context` | `array` | | `['input']` | | +| `reference` | `string` or `null` | | `null` | Override `context['reference']` | + +Example +------- + +```yaml +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask' + options: + level: warning + message: DEMO LOGGER +``` diff --git a/docs/reference/tasks/stopwatch_task.md b/docs/reference/tasks/stopwatch_task.md index f7ee724f..4953239b 100644 --- a/docs/reference/tasks/stopwatch_task.md +++ b/docs/reference/tasks/stopwatch_task.md @@ -13,14 +13,21 @@ Accepted inputs `any` +Possible outputs +---------------- + +None + +Options +------- + +None + Example ------- ```yaml -clever_age_process: - configurations: - project_prefix.stopwatch_example: - tasks: - stopwatch_example: - service: '@CleverAge\ProcessBundle\Task\Debug\StopwatchTask' -``` \ No newline at end of file +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\Debug\StopwatchTask' +``` diff --git a/docs/reference/tasks/transformer_task.md b/docs/reference/tasks/transformer_task.md index 4a8b5b21..efc98bcd 100644 --- a/docs/reference/tasks/transformer_task.md +++ b/docs/reference/tasks/transformer_task.md @@ -23,7 +23,18 @@ Possible outputs Options ------- -| Code | Type | Required | Default | Description | -| ---- | ---- | :------: | ------- | ----------- | -| `transformers` | `array` | **X** | | List of transformers, see [TransformerTrait](../traits/transformer_trait.md) | +| Code | Type | Required | Default | Description | +|----------------|---------|:---------:|----------|------------------------------------------------------------------------------| +| `transformers` | `array` | **X** | | List of transformers, see [TransformerTrait](../traits/transformer_trait.md) | +Example +------- + +```yaml +# Task configuration level +code: + service: '@CleverAge\ProcessBundle\Task\TransformerTask' + options: + transformers: + slugify: ~ +``` diff --git a/docs/reference/transformers/implode_transformer.md b/docs/reference/transformers/implode_transformer.md new file mode 100644 index 00000000..dad93ac2 --- /dev/null +++ b/docs/reference/transformers/implode_transformer.md @@ -0,0 +1,38 @@ +ImplodeTransformer +========================= + +Join array elements with a string + +This transformer uses the php internal function: https://www.php.net/manual/en/function.implode.php + +Task reference +-------------- + +* **Service**: `CleverAge\ProcessBundle\Transformer\String\ImplodeTransformer` +* **Transformer code**: `implode` + +Accepted inputs +--------------- + +`array` + +Possible outputs +---------------- + +`string` + +Options +------- + +| Code | Type | Required | Default | Description | +|-------------|----------|:--------:|---------|-------------| +| `separator` | `string` | **X** | `|` | | + +Examples +-------- + +```yaml +# Transformer options level +implode: + separator: '-' +``` diff --git a/docs/reference/transformers/mapping_transformer.md b/docs/reference/transformers/mapping_transformer.md index 9830542d..4971f66b 100644 --- a/docs/reference/transformers/mapping_transformer.md +++ b/docs/reference/transformers/mapping_transformer.md @@ -29,23 +29,23 @@ Possible outputs Options ------- -| Code | Type | Required | Default | Description | -| ---- | ---- | :------: | ------- | ----------- | -| `mapping` | `array` | **X** | | List of property => sub-mapping options. The property code can be a single string to be used as an array index, or a writable property path | -| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for the whole mapping | -| `keep_input` | `bool` | | `false` | Use input as the mapping destination (takes precedence on `initial_value`). Keep in mind that due to PHP behavior, arrays are cloned while objects are passed by reference | -| `initial_value` | `any` | | `[]` | Set the mapping destination | -| `merge_callback` | `callable` or `null` | | `null` | Allow to change how a property can be set in the destination | +| Code | Type | Required | Default | Description | +|------------------|----------------------|:---------:|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `mapping` | `array` | **X** | | List of property => sub-mapping options. The property code can be a single string to be used as an array index, or a writable property path | +| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for the whole mapping | +| `keep_input` | `bool` | | `false` | Use input as the mapping destination (takes precedence on `initial_value`). Keep in mind that due to PHP behavior, arrays are cloned while objects are passed by reference | +| `initial_value` | `any` | | `[]` | Set the mapping destination | +| `merge_callback` | `callable` or `null` | | `null` | Allow to change how a property can be set in the destination | Foreach property there is the following options. -| Code | Type | Required | Default | Description | -| ---- | ---- | :------: | ------- | ----------- | -| `code` | `string` or `array` or `null` | | `null` | A property path, or a list of property path. By default it would be the same as the destination property. Will be used as a source. The special value '.' access the whole object. | -| `constant` | `any` | | `null` | If not `null`, will be directly used as a source (takes precedence on `code`) | -| `set_null` | `bool` | | `false` | If `true`, `null` will be directly used as a source (takes precedence on `code`) | -| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for this source | -| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) | +| Code | Type | Required | Default | Description | +|------------------|-------------------------------|:---------:|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `code` | `string` or `array` or `null` | | `null` | A property path, or a list of property path. By default it would be the same as the destination property. Will be used as a source. The special value '.' access the whole object. | +| `constant` | `any` | | `null` | If not `null`, will be directly used as a source (takes precedence on `code`) | +| `set_null` | `bool` | | `false` | If `true`, `null` will be directly used as a source (takes precedence on `code`) | +| `ignore_missing` | `bool` | | `false` | Ignore property accessor errors for this source | +| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) | Examples -------- @@ -55,43 +55,39 @@ Examples - output: an array with keys "code", "label", "type", "reference", "required" and "slug" ```yaml -transform_data: # Task level - service: '@CleverAge\ProcessBundle\Task\TransformerTask' - options: - transformers: - mapping: - mapping: - code: # Simple mapping from "Code" to "code" - code: '[Code]' - "[label]": ~ # Value from "label" will be kept with the same name - type: # Get value from "type" and map values (with a default) - code: '[Type]' - transformers: - convert_value: - ignore_missing: true - map: - TEXTE: text - NUMERIQUE: number - LISTE_DEROULANTE: simpleselect - CHOIX_MULTIPLES: multiselect - DATE: date - default: - value: unknown - reference: # "null" column - set_null: true - required: # "true" column - constant: true - slug: # Get multiple sources, slugify them, and merge them - code: - name: '[Name]' - id: '[ID]' - transformers: - array_map: - transformers: - slugify: ~ - implode: - separator: '_' - outputs: [next_task] +# Transformer options level +mapping: + mapping: + code: # Simple mapping from "Code" to "code" + code: '[Code]' + "[label]": ~ # Value from "label" will be kept with the same name + type: # Get value from "type" and map values (with a default) + code: '[Type]' + transformers: + convert_value: + ignore_missing: true + map: + TEXTE: text + NUMERIQUE: number + LISTE_DEROULANTE: simpleselect + CHOIX_MULTIPLES: multiselect + DATE: date + default: + value: unknown + reference: # "null" column + set_null: true + required: # "true" column + constant: true + slug: # Get multiple sources, slugify them, and merge them + code: + name: '[Name]' + id: '[ID]' + transformers: + array_map: + transformers: + slugify: ~ + implode: + separator: '_' ``` * Mapping in depth, using objects @@ -99,23 +95,18 @@ transform_data: # T - output: an array with key "items", containing a list of array with key "name" ```yaml -transform_data: # Task level - service: '@CleverAge\ProcessBundle\Task\TransformerTask' - options: - transformers: # TransformerTask options - mapping: # Transformer code - mapping: # MappingTransformer options - items: # property code - code: 'productItems' # property options - transformers: # property options - array_map: # Transformer code - transformers: # ArrayMapTransformer options - mapping: # Transformer code - mapping: # MappingTransformer options - name: # property code - code: 'longName' # property options - - outputs: [next_task] +# Transformer options level +mapping: # Transformer code + mapping: # MappingTransformer options + items: # property code + code: 'productItems' # property options + transformers: + array_map: # Transformer code + transformers: # ArrayMapTransformer options + mapping: # Transformer code + mapping: # MappingTransformer options + name: # property code + code: 'longName' # property options ``` * Advanced property setter @@ -123,21 +114,17 @@ transform_data: # Ta - output: same object, with a modified "address.customer.hasFlag" ```yaml -transform_data: # Task level - service: '@CleverAge\ProcessBundle\Task\TransformerTask' - options: - transformers: - mapping: - keep_input: true - mapping: - address.customer.hasFlag: - code: address.postCode - transformers: - convert_value: - ignore_missing: true - map: - 69005: true - default: - value: false - outputs: [next_task] +# Transformer options level +mapping: + keep_input: true + mapping: + address.customer.hasFlag: + code: address.postCode + transformers: + convert_value: + ignore_missing: true + map: + 69005: true + default: + value: false ``` diff --git a/docs/reference/transformers/rules_transformer.md b/docs/reference/transformers/rules_transformer.md index fd65827a..71ecc40d 100644 --- a/docs/reference/transformers/rules_transformer.md +++ b/docs/reference/transformers/rules_transformer.md @@ -34,21 +34,21 @@ Without any matching rules, the value itself is returned. Options ------- -| Code | Type | Required | Default | Description | -| ---- | ---- | :------: | ------- | ----------- | -| `rules_set` | `array` | **X** | | Ordered list of rules, see bellow for details | -| `use_value_as_variables` | `bool` | | `false` | Use given value as an array of variable to inject in expression | -| `expression_variables` | `array` or `null` | | `[value]` | Name of variables injected in the expression at initialization time | +| Code | Type | Required | Default | Description | +|--------------------------|-------------------|:--------:|-----------|---------------------------------------------------------------------| +| `rules_set` | `array` | **X** | | Ordered list of rules, see bellow for details | +| `use_value_as_variables` | `bool` | | `false` | Use given value as an array of variable to inject in expression | +| `expression_variables` | `array` or `null` | | `[value]` | Name of variables injected in the expression at initialization time | Foreach rule there is the following options. -| Code | Type | Required | Default | Description | -| ---- | ---- | :------: | ------- | ----------- | -| `condition` | `string` or `null` | | `null` | An expression used to match a value | -| `default` | `bool` | | `false` | Mark this rule as a default rule. The given rule must be the last, cannot have a condition, and there cannot have 2 default in the same time | -| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) | -| `constant` | `any` | | `null` | If not `null`, given value will be directly output (takes precedence on `transformers`) | -| `set_null` | `bool` | | `false` | If `true`, `null` will be directly output (takes precedence on `constant`) | +| Code | Type | Required | Default | Description | +|----------------|--------------------|:---------:|---------|----------------------------------------------------------------------------------------------------------------------------------------------| +| `condition` | `string` or `null` | | `null` | An expression used to match a value | +| `default` | `bool` | | `false` | Mark this rule as a default rule. The given rule must be the last, cannot have a condition, and there cannot have 2 default in the same time | +| `transformers` | `array` | | `[]` | List of sub-transformers, see [TransformerTrait](../traits/transformer_trait.md) | +| `constant` | `any` | | `null` | If not `null`, given value will be directly output (takes precedence on `transformers`) | +| `set_null` | `bool` | | `false` | If `true`, `null` will be directly output (takes precedence on `constant`) | Examples -------- @@ -60,15 +60,15 @@ Examples ```yaml # Transformer options level rules: - rules_set: - - condition: 'value["order"].origin === "marketplace"' - transformers: - property_accessor: - property_path: '[customer].id' - - condition: 'value["order"].origin === "e-commerce"' - constant: 1234 - - default: true - set_null: true + rules_set: + - condition: 'value["order"].origin === "marketplace"' + transformers: + property_accessor: + property_path: '[customer].id' + - condition: 'value["order"].origin === "e-commerce"' + constant: 1234 + - default: true + set_null: true ``` * Use value as variables @@ -79,15 +79,15 @@ rules: ```yaml # Transformer options level rules: - use_value_as_variables: true - expression_variables: [order, customer] - rules_set: - - condition: 'order.origin === "marketplace"' - transformers: - property_accessor: - property_path: '[customer].id' - - condition: 'order.origin === "e-commerce"' - constant: 1234 - - default: true - set_null: true + use_value_as_variables: true + expression_variables: [order, customer] + rules_set: + - condition: 'order.origin === "marketplace"' + transformers: + property_accessor: + property_path: '[customer].id' + - condition: 'order.origin === "e-commerce"' + constant: 1234 + - default: true + set_null: true ``` diff --git a/docs/reference/transformers/slugify_transformer.md b/docs/reference/transformers/slugify_transformer.md new file mode 100644 index 00000000..cadab337 --- /dev/null +++ b/docs/reference/transformers/slugify_transformer.md @@ -0,0 +1,39 @@ +SlugifyTransformer +========================= + +Strip whitespace (or other characters) from the beginning and end of a string + +This transformer uses the php internal function: https://www.php.net/manual/en/class.transliterator.php + +Task reference +-------------- + +* **Service**: `CleverAge\ProcessBundle\Transformer\String\SlugifyTransformer` +* **Transformer code**: `slugify` + +Accepted inputs +--------------- + +Any value that can be cast to string. + +Possible outputs +---------------- + +`string` + +Options +------- + +| Code | Type | Required | Default | Description | +|------------------|----------|:---------:|----------------------------------------|--------------------------------| +| `transliterator` | `string` | | `NFD; [:Nonspacing Mark:] Remove; NFC` | Used to create \Transliterator | +| `replace` | `string` | | `/[^a-z0-9]+/` | Used on preg_replace | +| `separator` | `string` | | `_` | Used on preg_replace | + +Examples +-------- + +```yaml +# Transformer options level +slugify: ~ +```