Skip to content

Commit

Permalink
bug #1908 [Fix] Revert removing twig_component.controllers_json (sm…
Browse files Browse the repository at this point in the history
…nandre)

This PR was merged into the 2.x branch.

Discussion
----------

[Fix] Revert removing `twig_component.controllers_json`

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Issues        | Fix #
| License       | MIT

I [removed](https://github.com/symfony/ux/pull/1823/files) this key because it was an [mistake](0284c0a) (never used, documented, or written in recipes)

I wrongly did not consider this a BC break, and it was.

This PR re-adds the configuration key and deprecates it instead.

--

Should this be acceptable in a hotfix version like 2.18.1 ?

Commits
-------

6c397d5 [Fix] Revert removing `twig_component.controllers_json`
  • Loading branch information
kbond committed Jun 11, 2024
2 parents 5099e8b + 6c397d5 commit 4ca6f2f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +23,8 @@
*/
class TwigComponentExtensionTest extends TestCase
{
use ExpectDeprecationTrait;

public function testDataCollectorWithDebugMode()
{
$container = $this->createContainer();
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit 4ca6f2f

Please sign in to comment.