8000 feature #21835 [FrameworkBundle][Routing] Move RoutingResolverPass to… · symfony/symfony@2620411 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2620411

Browse files
committed
feature #21835 [FrameworkBundle][Routing] Move RoutingResolverPass to the Routing component (chalasr)
This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle][Routing] Move RoutingResolverPass to the Routing component | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 32be16b Move RoutingResolverPass to the Routing component
2 parents 6bfa483 + 32be16b commit 2620411

File tree

9 files changed

+101
-19
lines changed

9 files changed

+101
-19
lines changed

UPGRADE-3.3.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ FrameworkBundle
162162
has been deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass`
163163
class instead.
164164

165+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass`
166+
class has been deprecated and will be removed in 4.0. Use the
167+
`Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` class instead.
168+
165169
HttpKernel
166170
-----------
167171

UPGRADE-4.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ FrameworkBundle
221221
has been removed. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass`
222222
class instead.
223223

224+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass`
225+
class has been removed. Use the
226+
`Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` class instead.
227+
224228
HttpFoundation
225229
---------------
226230

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ CHANGELOG
2727
`render()`, `renderView()` and `stream()` methods can only use Twig (using the Templating component is not supported).
2828
The `json()` method requires the Serializer component (use `Symfony\Component\HttpFoundation\JsonResponse` directly if
2929
you do not want to use the Serializer).
30-
* Deprecated `ControllerArgumentValueResolverPass`. Use
30+
* Deprecated `ControllerArgumentValueResolverPass`. Use
3131
`Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` instead
32+
* Deprecated `RoutingResolverPass`, use `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` instead
3233

3334
3.2.0
3435
-----

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RoutingResolverPass.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,17 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Reference;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14+
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass as BaseRoutingResolverPass;
15+
16+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use %s instead.', RoutingResolverPass::class, BaseRoutingResolverPass::class), E_USER_DEPRECATED);
1717

1818
/**
1919
* Adds tagged routing.loader services to routing.resolver service.
2020
*
2121
* @author Fabien Potencier <fabien@symfony.com>
22+
*
23+
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseRoutingResolverPass}
2224
*/
23-
class RoutingResolverPass implements CompilerPassInterface
25+
class RoutingResolverPass extends BaseRoutingResolverPass
2426
{
25-
public function process(ContainerBuilder $container)
26-
{
27-
if (false === $container->hasDefinition('routing.resolver')) {
28-
return;
29-
}
30-
31-
$definition = $container->getDefinition('routing.resolver');
32-
33-
foreach ($container->findTaggedServiceIds('routing.loader') as $id => $attributes) {
34-
$definition->addMethodCall('addLoader', array(new Reference($id)));
35-
}
36-
}
3727
}

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

9E88
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass;
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2222
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
23-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
2423
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
2524
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
2625
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
@@ -37,6 +36,7 @@
3736
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
3837
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
3938
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
39+
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
4040
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
4141
use Symfony\Component\Debug\ErrorHandler;
4242
use Symfony\Component\DependencyInjection\ContainerBuilder;

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"symfony/polyfill-mbstring": "~1.0",
2828
"symfony/filesystem": "~2.8|~3.0",
2929
"symfony/finder": "~2.8|~3.0",
30-
"symfony/routing": "~3.1.10|^3.2.3",
30+
"symfony/routing": "~3.3",
3131
"symfony/security-core": "~2.8|~3.0",
3232
"symfony/security-csrf": "~2.8|~3.0",
3333
"symfony/stopwatch": "~2.8|~3.0",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Reference;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
18+
/**
19+
* Adds tagged routing.loader services to routing.resolver service.
20+
*
21+
* @author Fabien Potencier <fabien@symfony.com>
22+
*/
23+
class RoutingResolverPass implements CompilerPassInterface
24+
{
25+
private $resolverServiceId;
26+
private $loaderTag;
27+
28+
public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader')
29+
{
30+
$this->resolverServiceId = $resolverServiceId;
31+
$this->loaderTag = $loaderTag;
32+
}
33+
34+
public function process(ContainerBuilder $container)
35+
{
36+
if (false === $container->hasDefinition($this->resolverServiceId)) {
37+
return;
38+
}
39+
40+
$definition = $container->getDefinition($this->resolverServiceId);
41+
42+
foreach ($container->findTaggedServiceIds($this->loaderTag) as $id => $attributes) {
43+
$definition->addMethodCall('addLoader', array(new Reference($id)));
44+
}
45+
}
46+
}
Lines changed: 36 additions & 0 deletions
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 <fabien@symfony.com>
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\Config\Loader\LoaderResolver;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
19+
20+
class RoutingResolverPassTest extends TestCase
21+
{
22+
public function testProcess()
23+
{
24+
$container = new ContainerBuilder();
25+
$container->register('routing.resolver', LoaderResolver::class);
26+
$container->register('loader1')->addTag('routing.loader');
27+
$container->register('loader2')->addTag('routing.loader');
28+
29+
(new RoutingResolverPass())->process($container);
30+
31+
$this->assertEquals(
32+
array(array('addLoader', array(new Reference('loader1'))), array('addLoader', array(new Reference('loader2')))),
33+
$container->getDefinition('routing.resolver')->getMethodCalls()
34+
);
35+
}
36+
}

src/Symfony/Component/Routing/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"symfony/http-foundation": "~2.8|~3.0",
2424
"symfony/yaml": "~2.8|~3.0",
2525
"symfony/expression-language": "~2.8|~3.0",
26+
"symfony/dependency-injection": "~2.8|~3.0",
2627
"doctrine/annotations": "~1.0",
2728
"doctrine/common": "~2.2",
2829
"psr/log": "~1.0"

0 commit comments

Comments
 (0)
0