diff --git a/CHANGELOG.md b/CHANGELOG.md index 771db5cb..f219f6b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Latest ## Fixes * [#434](https://github.com/cleverage/process-bundle/issues/434) Signals: when the same SIGINT or SIGTERM is received again while a process is running, the command exits right away, as documented. The console application dispatches the same event at each signal, whose exit stayed aborted by the first signal. Add tests. * [#436](https://github.com/cleverage/process-bundle/issues/436) `xpath_evaluator`: a boolean expression whose value is `false` (`boolean()`, `not()`, a false comparison) returns `false`, instead of throwing `Invalid xpath query '...': unknown error`. Only an expression reporting libxml errors is invalid. Add tests. +* [#438](https://github.com/cleverage/process-bundle/issues/438) Generic transformers: the codes of their `transformers` and `contextual_options` keep their dashes, as the codes of the processes, tasks and generic transformers since 5.7. A generic transformer referencing a generic transformer whose code has a dash no longer triggers the deprecation of its former name, and a transformer service whose code has a dash is found. Update documentation, add tests. v5.8 ----- diff --git a/docs/reference/03-generic_transformers_definition.md b/docs/reference/03-generic_transformers_definition.md index f45bc200..12b635f6 100644 --- a/docs/reference/03-generic_transformers_definition.md +++ b/docs/reference/03-generic_transformers_definition.md @@ -75,4 +75,5 @@ clever_age_process: ``` As any transformer code, generic transformer codes must be unique: use a prefix to avoid conflicts. A dash is kept in -the code (it was replaced by an underscore before 5.7, the former name is deprecated). +the code (it was replaced by an underscore before 5.7, the former name is deprecated), as in the codes of the +transformers and of the contextual options of a generic transformer. diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index a933a38b..666d90ac 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -104,12 +104,16 @@ protected function appendTransformerConfigDefinition(NodeBuilder $definition): v ->arrayNode('contextual_options') ->info('Options of the transformer (code: definition with required, default, default_is_null), injected in the "transformers" with "{{ code }}"') ->example(['delimiter' => ['default' => ',']]) + // Keep the dashes of the option codes, as written in the options given to the transformer and in "{{ code }}" + ->normalizeKeys(false) ->variablePrototype() ->end() ->end() ->arrayNode('transformers') ->info('Transformers applied in sequence, by code, with their options') ->example(['explode' => ['delimiter' => '{{ separator }}']]) + // Keep the dashes of the transformer codes (the former name of a generic transformer is deprecated) + ->normalizeKeys(false) ->variablePrototype() ->end() ->end(); diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index ae86b00c..2adbfa4f 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -278,6 +278,13 @@ public function testTheDashesOfTheCodesAreKept(): void self::assertSame(['to-upper'], array_keys($config['generic_transformers'])); self::assertSame(['demo.x-y'], array_keys($config['configurations'])); self::assertSame(['first-task', 'next-task'], array_keys($config['configurations']['demo.x-y']['tasks'])); + // The transformers and the contextual options of a generic transformer, referenced by their code + $config = $this->process(['generic_transformers' => ['wrap' => [ + 'contextual_options' => ['wrap-format' => ['default' => '[%s]']], + 'transformers' => ['to-upper' => null, 'sprintf' => ['format' => '{{ wrap-format }}']], + ]]]); + self::assertSame(['wrap-format'], array_keys($config['generic_transformers']['wrap']['contextual_options'])); + self::assertSame(['to-upper', 'sprintf'], array_keys($config['generic_transformers']['wrap']['transformers'])); // The keys of the options are still normalized self::assertArrayHasKey('error_outputs', $this->process(['configurations' => ['p' => ['tasks' => [ 't' => ['task' => 'transformer', 'error-outputs' => ['u']],