Skip to content

Commit 6c397d5

Browse files
committed
[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 ?
1 parent 7a84975 commit 6c397d5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ public function getConfigTreeBuilder(): TreeBuilder
186186
->info('Enables the profiler for Twig Component (in debug mode)')
187187
->defaultValue('%kernel.debug%')
188188
->end()
189+
->scalarNode('controllers_json')
190+
->setDeprecated('symfony/ux-twig-component', '2.18', 'The "twig_component.controllers_json" config option is deprecated, and will be removed in 3.0.')
191+
->defaultNull()
192+
->end()
189193
->end();
190194

191195
return $treeBuilder;

src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\TwigComponent\Test\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1718
use Symfony\UX\TwigComponent\DependencyInjection\TwigComponentExtension;
@@ -22,6 +23,8 @@
2223
*/
2324
class TwigComponentExtensionTest extends TestCase
2425
{
26+
use ExpectDeprecationTrait;
27+
2528
public function testDataCollectorWithDebugMode()
2629
{
2730
$container = $this->createContainer();
@@ -66,6 +69,26 @@ public function testDataCollectorWithoutDebugMode()
6669
$this->assertFalse($container->hasDefinition('ux.twig_component.data_collector'));
6770
}
6871

72+
/**
73+
* @group legacy
74+
*/
75+
public function testSettingControllerJsonKeyTriggerDeprecation()
76+
{
77+
$container = $this->createContainer();
78+
$container->setParameter('kernel.debug', true);
79+
$container->registerExtension(new TwigComponentExtension());
80+
$container->loadFromExtension('twig_component', [
81+
'defaults' => [],
82+
'anonymous_template_directory' => 'components/',
83+
'profiler' => false,
84+
'controllers_json' => null,
85+
]);
86+
87+
$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.');
88+
89+
$this->compileContainer($container);
90+
}
91+
6992
private function createContainer()
7093
{
7194
$container = new ContainerBuilder(new ParameterBag([

0 commit comments

Comments
 (0)