From 6c397d518a6547ef33fde5be48363712c7ea008a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Tue, 11 Jun 2024 14:19:31 +0200 Subject: [PATCH] [Fix] Revert removing `twig_component.controllers_json` I removed this key because it was an mistake (never used, documented, or written in recipes) I wrongly did not consider this a BC, and it was. So this PR re-adds the configuration key and deprecates it instead. Should this be acceptable in a hotfix version like 2.18.1 ? --- .../TwigComponentExtension.php | 4 ++++ .../TwigComponentExtensionTest.php | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php b/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php index 4ac41f87f73..0027e319ed0 100644 --- a/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php +++ b/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php @@ -186,6 +186,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->info('Enables the profiler for Twig Component (in debug mode)') ->defaultValue('%kernel.debug%') ->end() + ->scalarNode('controllers_json') + ->setDeprecated('symfony/ux-twig-component', '2.18', 'The "twig_component.controllers_json" config option is deprecated, and will be removed in 3.0.') + ->defaultNull() + ->end() ->end(); return $treeBuilder; diff --git a/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php b/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php index 7b34a5c18cf..cf983f1fb42 100644 --- a/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php +++ b/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php @@ -12,6 +12,7 @@ namespace Symfony\UX\TwigComponent\Test\DependencyInjection; use PHPUnit\Framework\TestCase; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\UX\TwigComponent\DependencyInjection\TwigComponentExtension; @@ -22,6 +23,8 @@ */ class TwigComponentExtensionTest extends TestCase { + use ExpectDeprecationTrait; + public function testDataCollectorWithDebugMode() { $container = $this->createContainer(); @@ -66,6 +69,26 @@ public function testDataCollectorWithoutDebugMode() $this->assertFalse($container->hasDefinition('ux.twig_component.data_collector')); } + /** + * @group legacy + */ + public function testSettingControllerJsonKeyTriggerDeprecation() + { + $container = $this->createContainer(); + $container->setParameter('kernel.debug', true); + $container->registerExtension(new TwigComponentExtension()); + $container->loadFromExtension('twig_component', [ + 'defaults' => [], + 'anonymous_template_directory' => 'components/', + 'profiler' => false, + 'controllers_json' => null, + ]); + + $this->expectDeprecation('Since symfony/ux-twig-component 2.18: The "twig_component.controllers_json" config option is deprecated, and will be removed in 3.0.'); + + $this->compileContainer($container); + } + private function createContainer() { $container = new ContainerBuilder(new ParameterBag([