Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd3e3d8

Browse filesBrowse files
committed
Move ControllerArgumentValueResolverPass to the HttpKernel component
1 parent 36dacbc commit cd3e3d8
Copy full SHA for cd3e3d8

File tree

9 files changed

+136
-18
lines changed
Filter options

9 files changed

+136
-18
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ FrameworkBundle
143143
deprecated and will be removed in 4.0. Use the `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass`
144144
class instead.
145145

146+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass` class
147+
has been removed. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass`
148+
class instead
149+
146150
HttpKernel
147151
-----------
148152

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ FrameworkBundle
202202
removed. Use the `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass`
203203
class instead.
204204

205+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass` class
206+
has been removed. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass`
207+
class instead
208+
205209
HttpFoundation
206210
---------------
207211

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ CHANGELOG
2020
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass`.
2121
Use `Symfony\Component\Console\DependencyInjection\ConfigCachePass` instead.
2222
* Deprecated `PropertyInfoPass`, use `Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass` instead
23+
* Deprecated `ControllerArgumentValueResolverPass`.
24+
Use `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` instead
2325

2426
3.2.0
2527
-----

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ControllerArgumentValueResolverPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ControllerArgumentValueResolverPass.php
+6-17Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,17 @@
1111

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

14-
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16-
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17-
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass instead.', ControllerArgumentValueResolverPass::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass as BaseControllerArgumentValueResolverPass;
1817

1918
/**
2019
* Gathers and configures the argument value resolvers.
2120
*
2221
* @author Iltar van der Berg <kjarli@gmail.com>
22+
*
23+
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseControllerArgumentValueResolverPass}
2324
*/
24-
class ControllerArgumentValueResolverPass implements CompilerPassInterface
25+
class ControllerArgumentValueResolverPass extends BaseControllerArgumentValueResolverPass
2526
{
26-
use PriorityTaggedServiceTrait;
27-
28-
public function process(ContainerBuilder $container)
29-
{
30-
if (!$container->hasDefinition('argument_resolver')) {
31-
return;
32-
}
33-
34-
$definition = $container->getDefinition('argument_resolver');
35-
$argumentResolvers = $this->findAndSortTaggedServices('controller.argument_value_resolver', $container);
36-
$definition->replaceArgument(1, new IteratorArgument($argumentResolvers));
37-
}
3827
}

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass;
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass;
21-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass;
2221
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2322
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
2423
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
@@ -36,6 +35,7 @@
3635
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass;
3736
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
3837
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
38+
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
3939
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
4040
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
4141
use Symfony\Component\Debug\ErrorHandler;

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
use Symfony\Component\DependencyInjection\Reference;
1919
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
2020

21+
/**
22+
* @group legacy
23+
*/
2124
class ControllerArgumentValueResolverPassTest extends TestCase
2225
{
2326
public function testServicesAreOrderedAccordingToPriority()

‎src/Symfony/Component/HttpKernel/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CHANGELOG
1313

1414
* deprecated `DataCollector::varToString()`, use `cloneVar()` instead
1515
* changed surrogate capability name in `AbstractSurrogate::addSurrogateCapability` to 'symfony'
16+
* Added `ControllerArgumentValueResolverPass`
1617

1718
3.1.0
1819
-----
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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\HttpKernel\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
19+
/**
20+
* Gathers and configures the argument value resolvers.
21+
*
22+
* @author Iltar van der Berg <kjarli@gmail.com>
23+
*/
24+
class ControllerArgumentValueResolverPass implements CompilerPassInterface
25+
{
26+
use PriorityTaggedServiceTrait;
27+
28+
private $argumentResolverService;
29+
private $argumentValueResolverTag;
30+
31+
public function __construct($argumentResolverService = 'argument_resolver', $argumentValueResolverTag = 'controller.argument_value_resolver')
32+
{
33+
$this->argumentResolverService = $argumentResolverService;
34+
$this->argumentValueResolverTag = $argumentValueResolverTag;
35+
}
36+
37+
public function process(ContainerBuilder $container)
38+
{
39+
if (!$container->hasDefinition($this->argumentResolverService)) {
40+
return;
41+
}
42+
43+
$container
44+
->getDefinition($this->argumentResolverService)
45+
->replaceArgument(1, new IteratorArgument($this->findAndSortTaggedServices($this->argumentValueResolverTag, $container)))
46+
;
47+
}
48+
}
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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\HttpKernel\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\HttpKernel\Controller\ArgumentResolver;
19+
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
20+
21+
class ControllerArgumentValueResolverPassTest extends TestCase
22+
{
23+
public function testServicesAreOrderedAccordingToPriority()
24+
{
25+
$services = array(
26+
'n3' => array(array()),
27+
'n1' => array(array('priority' => 200)),
28+
'n2' => array(array('priority' => 100)),
29+
);
30+
31+
$expected = array(
32+
new Reference('n1'),
33+
new Reference('n2'),
34+
new Reference('n3'),
35+
);
36+
37+
$definition = new Definition(ArgumentResolver::class, array(null, array()));
38+
$container = new ContainerBuilder();
39+
$container->setDefinition('argument_resolver', $definition);
40+
41+
foreach ($services as $id => list($tag)) {
42+
$container->register($id)->addTag('controller.argument_value_resolver', $tag);
43+
}
44+
45+
(new ControllerArgumentValueResolverPass())->process($container);
46+
$this->assertEquals($expected, $definition->getArgument(1)->getValues());
47+
}
48+
49+
public function testReturningEmptyArrayWhenNoService()
50+
{
51+
$definition = new Definition(ArgumentResolver::class, array(null, array()));
52+
$container = new ContainerBuilder();
53+
$container->setDefinition('argument_resolver', $definition);
54+
55+
(new ControllerArgumentValueResolverPass())->process($container);
56+
$this->assertEquals(array(), $definition->getArgument(1)->getValues());
57+
}
58+
59+
public function testNoArgumentResolver()
60+
{
61+
$container = new ContainerBuilder();
62+
63+
(new ControllerArgumentValueResolverPass())->process($container);
64+
65+
$this->assertFalse($container->hasDefinition('argument_resolver'));
66+
}
67+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.