Skip to content

Commit 4ef4e55

Browse files
committed
[StimulusBundle] Remove deprecations for 3.0
1 parent d1b53cf commit 4ef4e55

14 files changed

+81
-478
lines changed

UPGRADE-3.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class MyLiveComponent {
6262
* Options `authReferrerPolicy`, `mapIds`, `channel`, `solutionChannel` have been added
6363
* Options `ìd`, `nonce`, `retries`, `url` have been removed
6464

65+
## StimulusBundle
66+
67+
* The Twig function `ux_controller_link_tags()` has been removed, which requires Symfony AssetMapper >=6.4,
68+
run `composer require symfony/asset-mapper:>=6.4` if you don't have it installed yet.
69+
6570
## Swup
6671

6772
* The package has been removed, see the [previous README](https://raw.githubusercontent.com/symfony/ux/refs/heads/2.x/src/Turbo/README.md)

src/StimulusBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Minimum required Symfony version is now 6.4
66
- Minimum required PHP version is now 8.2
7+
- Remove Twig function `ux_controller_link_tags()`, which requires Symfony AssetMapper >=6.4
78

89
## 2.30
910

src/StimulusBundle/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"twig/twig": "^2.15.3|^3.8",
2222
"symfony/deprecation-contracts": "^2.0|^3.0"
2323
},
24+
"conflict": {
25+
"symfony/asset-mapper": "<6.4"
26+
},
2427
"require-dev": {
2528
"symfony/asset-mapper": "^6.4|^7.0|^8.0",
2629
"symfony/framework-bundle": "^6.4|^7.0|^8.0",

src/StimulusBundle/config/services.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Symfony\UX\StimulusBundle\AssetMapper\StimulusLoaderJavaScriptCompiler;
1616
use Symfony\UX\StimulusBundle\Helper\StimulusHelper;
1717
use Symfony\UX\StimulusBundle\Twig\StimulusTwigExtension;
18-
use Symfony\UX\StimulusBundle\Twig\UxControllersTwigExtension;
19-
use Symfony\UX\StimulusBundle\Twig\UxControllersTwigRuntime;
2018
use Symfony\UX\StimulusBundle\Ux\UxPackageReader;
2119
use Twig\Environment;
2220

@@ -45,17 +43,6 @@
4543
])
4644

4745
// symfony/asset-mapper services
48-
->set('stimulus.ux_controllers_twig_extension', UxControllersTwigExtension::class)
49-
->tag('twig.extension')
50-
51-
->set('stimulus.ux_controllers_twig_runtime', UxControllersTwigRuntime::class)
52-
->args([
53-
service('stimulus.asset_mapper.controllers_map_generator'),
54-
service('asset_mapper'),
55-
service('stimulus.asset_mapper.ux_package_reader'),
56-
param('kernel.project_dir'),
57-
])
58-
->tag('twig.runtime')
5946

6047
->set('stimulus.asset_mapper.controllers_map_generator', ControllersMapGenerator::class)
6148
->args([

src/StimulusBundle/doc/index.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,6 @@ will import all your custom controllers as well as those from ``controllers.json
416416
It will also dynamically enable "debug" mode in Stimulus when your application
417417
is running in debug mode.
418418

419-
.. tip::
420-
421-
For AssetMapper 6.3 only, you also need a ``{{ ux_controller_link_tags() }}``
422-
in ``base.html.twig``. This is not needed in AssetMapper 6.4+.
423419

424420
With WebpackEncoreBundle
425421
~~~~~~~~~~~~~~~~~~~~~~~~

src/StimulusBundle/src/DependencyInjection/Compiler/RemoveAssetMapperServicesCompiler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class RemoveAssetMapperServicesCompiler implements CompilerPassInterface
2424
public function process(ContainerBuilder $container): void
2525
{
2626
if (!$container->hasDefinition('asset_mapper')) {
27-
$container->removeDefinition('stimulus.ux_controllers_twig_runtime');
2827
$container->removeDefinition('stimulus.asset_mapper.controllers_map_generator');
2928
$container->removeDefinition('stimulus.asset_mapper.loader_javascript_compiler');
3029
}

src/StimulusBundle/src/Twig/UxControllersTwigExtension.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/StimulusBundle/src/Twig/UxControllersTwigRuntime.php

Lines changed: 0 additions & 171 deletions
This file was deleted.

src/StimulusBundle/tests/AssetMapper/AutoImportLocatorTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222

2323
class AutoImportLocatorTest extends TestCase
2424
{
25-
protected function setUp(): void
26-
{
27-
if (!class_exists(ImportMapConfigReader::class)) {
28-
$this->markTestSkipped('Test requires AssetMapper >= 6.4.');
29-
}
30-
}
31-
3225
public function testLocateAutoImportCanHandleAssetMapperPath()
3326
{
3427
$assetMapper = $this->createMock(AssetMapperInterface::class);

src/StimulusBundle/tests/AssetMapper/ControllersMapGeneratorTest.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\AssetMapper\AssetMapperInterface;
16-
use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader;
1716
use Symfony\Component\AssetMapper\MappedAsset;
1817
use Symfony\UX\StimulusBundle\AssetMapper\AutoImportLocator;
1918
use Symfony\UX\StimulusBundle\AssetMapper\ControllersMapGenerator;
@@ -54,17 +53,11 @@ public function testGetControllersMap()
5453
$packageReader = new UxPackageReader(__DIR__.'/../fixtures');
5554

5655
$autoImportLocator = $this->createMock(AutoImportLocator::class);
57-
if (class_exists(ImportMapConfigReader::class)) {
58-
$autoImportLocator->expects($this->any())
59-
->method('locateAutoImport')
60-
->willReturnCallback(function ($path) {
61-
return new MappedControllerAutoImport('/path/to'.$path, false);
62-
});
63-
} else {
64-
// @legacy for AssetMapper 6.3
65-
$autoImportLocator->expects($this->never())
66-
->method('locateAutoImport');
67-
}
56+
$autoImportLocator->expects($this->any())
57+
->method('locateAutoImport')
58+
->willReturnCallback(function ($path) {
59+
return new MappedControllerAutoImport('/path/to'.$path, false);
60+
});
6861

6962
$generator = new ControllersMapGenerator(
7063
$mapper,
@@ -106,11 +99,7 @@ public function testGetControllersMap()
10699
$this->assertSame('fake-vendor/ux-package1/package-controller-second.js', $controllerSecond->asset->logicalPath);
107100
// lazy from user's controller.json
108101
$this->assertTrue($controllerSecond->isLazy);
109-
// @legacy: assert can be without the conditional for AssetMapper 6.4+
110-
if (class_exists(ImportMapConfigReader::class)) {
111-
// 4 auto imports from package.json
112-
$this->assertCount(4, $controllerSecond->autoImports);
113-
}
102+
$this->assertCount(4, $controllerSecond->autoImports);
114103

115104
$helloControllerFromPackage = $map['fake-vendor--ux-package2--hello-controller'];
116105
$this->assertSame('fake-vendor/ux-package2/package-hello-controller.js', $helloControllerFromPackage->asset->logicalPath);

0 commit comments

Comments
 (0)