Skip to content

Commit e21b312

Browse files
Merge branch '6.4' into 7.0
* 6.4: [Messenger] Fix requiring symfony/deprecation-contracts [AssetMapper] Warn of missing or incompat dependencies Added missing Uzbek translations. [Messenger] [Sqs] Add `AddFifoStamp` middleware DX: nullable_type_declaration [HtmlSanitizer] Add support for sanitizing unlimited length of HTML document [Validator] Add missing Finnish translations [FrameworkBundle][Routing][Translation][Workflow] Move some compiler passes from FrameworkBundle to components
2 parents 572421c + 301c798 commit e21b312

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CHANGELOG
2020
* Deprecate `AnnotationClassLoader`, use `AttributeClassLoader` instead
2121
* Deprecate `AnnotationDirectoryLoader`, use `AttributeDirectoryLoader` instead
2222
* Deprecate `AnnotationFileLoader`, use `AttributeFileLoader` instead
23+
* Add `AddExpressionLanguageProvidersPass` (moved from `FrameworkBundle`)
2324

2425
6.2
2526
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Reference;
17+
18+
/**
19+
* Registers the expression language providers.
20+
*
21+
* @author Fabien Potencier <[email protected]>
22+
*/
23+
class AddExpressionLanguageProvidersPass implements CompilerPassInterface
24+
{
25+
public function process(ContainerBuilder $container): void
26+
{
27+
if (!$container->has('router.default')) {
28+
return;
29+
}
30+
31+
$definition = $container->findDefinition('router.default');
32+
foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) {
33+
$definition->addMethodCall('addExpressionLanguageProvider', [new Reference($id)]);
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Tests\DependencyInjection;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Definition;
17+
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\Routing\DependencyInjection\AddExpressionLanguageProvidersPass;
19+
20+
class AddExpressionLanguageProvidersPassTest extends TestCase
21+
{
22+
public function testProcessForRouter()
23+
{
24+
$container = new ContainerBuilder();
25+
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
26+
27+
$definition = new Definition(\stdClass::class);
28+
$definition->addTag('routing.expression_language_provider');
29+
$container->setDefinition('some_routing_provider', $definition->setPublic(true));
30+
31+
$container->register('router.default', \stdClass::class)->setPublic(true);
32+
$container->compile();
33+
34+
$router = $container->getDefinition('router.default');
35+
$calls = $router->getMethodCalls();
36+
$this->assertCount(1, $calls);
37+
$this->assertEquals('addExpressionLanguageProvider', $calls[0][0]);
38+
$this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]);
39+
}
40+
41+
public function testProcessForRouterAlias()
42+
{
43+
$container = new ContainerBuilder();
44+
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
45+
46+
$definition = new Definition(\stdClass::class);
47+
$definition->addTag('routing.expression_language_provider');
48+
$container->setDefinition('some_routing_provider', $definition->setPublic(true));
49+
50+
$container->register('my_router', \stdClass::class)->setPublic(true);
51+
$container->setAlias('router.default', 'my_router');
52+
$container->compile();
53+
54+
$router = $container->getDefinition('my_router');
55+
$calls = $router->getMethodCalls();
56+
$this->assertCount(1, $calls);
57+
$this->assertEquals('addExpressionLanguageProvider', $calls[0][0]);
58+
$this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]);
59+
}
60+
}

0 commit comments

Comments
 (0)