From ae65aa0a926f644a6e511a548a0bc9215f555cfc Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 6 Apr 2021 14:07:06 +0200 Subject: [PATCH] Add deprecation --- src/DependencyInjection/Configuration.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 940dbf5e..b1887848 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -36,7 +36,20 @@ public function getConfigTreeBuilder() ->scalarNode('revision_field_name')->defaultValue('rev')->end() ->scalarNode('revision_type_field_name')->defaultValue('revtype')->end() ->scalarNode('revision_table_name')->defaultValue('revisions')->end() - ->scalarNode('revision_id_field_type')->defaultValue('integer')->end() + ->scalarNode('revision_id_field_type') + ->defaultValue('integer') + // NEXT_MAJOR: Use validate() instead. + ->beforeNormalization() + ->always(static function ($value) { + if (null !== $value && !\in_array($value, ['integer', 'string'], true)) { + @trigger_error(sprintf( + 'Passing another value than "integer" and "string" as "revision_id_field_type" is deprecated' + .' since sonata-project/entity-audit-bundle 1.3 and will throw an error in version 2.0.', + ), \E_USER_DEPRECATED); + } + }) + ->end() + ->end() ->arrayNode('service') ->addDefaultsIfNotSet() ->children()