Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit30bc005

Browse files
committed
Move ControllerArgumentValueResolverPass to the HttpKernel component
1 parent69374da commit30bc005

File tree

9 files changed

+136
-18
lines changed

9 files changed

+136
-18
lines changed

‎UPGRADE-3.3.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ FrameworkBundle
148148

149149
* Extending`ConstraintValidatorFactory` is deprecated and won't be supported in 4.0.
150150

151+
* The`Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass` class
152+
has been removed. Use the`Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass`
153+
class instead.
154+
151155
HttpKernel
152156
-----------
153157

‎UPGRADE-4.0.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ FrameworkBundle
207207

208208
* Extending`ConstraintValidatorFactory` is not supported anymore.
209209

210+
* The`Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass` class
211+
has been removed. Use the`Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass`
212+
class instead.
213+
210214
HttpFoundation
211215
---------------
212216

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ CHANGELOG
2121
Use`Symfony\Component\Console\DependencyInjection\ConfigCachePass` instead.
2222
* Deprecated`PropertyInfoPass`, use`Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass` instead
2323
* Deprecated extending`ConstraintValidatorFactory`
24+
* Deprecated`ControllerArgumentValueResolverPass`. Use
25+
`Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` instead
2426

2527
3.2.0
2628
-----

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

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

1212
namespaceSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
useSymfony\Component\DependencyInjection\Argument\IteratorArgument;
15-
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16-
useSymfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17-
useSymfony\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+
useSymfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPassasBaseControllerArgumentValueResolverPass;
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 ControllerArgumentValueResolverPassimplements CompilerPassInterface
25+
class ControllerArgumentValueResolverPassextends BaseControllerArgumentValueResolverPass
2526
{
26-
use PriorityTaggedServiceTrait;
27-
28-
publicfunctionprocess(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,newIteratorArgument($argumentResolvers));
37-
}
3827
}

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

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
useSymfony\Component\DependencyInjection\Reference;
1919
useSymfony\Component\HttpKernel\Controller\ArgumentResolver;
2020

21+
/**
22+
* @group legacy
23+
*/
2124
class ControllerArgumentValueResolverPassTestextends TestCase
2225
{
2326
publicfunctiontestServicesAreOrderedAccordingToPriority()

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

Lines 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
-----
Lines 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+
namespaceSymfony\Component\HttpKernel\DependencyInjection;
13+
14+
useSymfony\Component\DependencyInjection\Argument\IteratorArgument;
15+
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
useSymfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
17+
useSymfony\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 ControllerArgumentValueResolverPassimplements CompilerPassInterface
25+
{
26+
use PriorityTaggedServiceTrait;
27+
28+
private$argumentResolverService;
29+
private$argumentValueResolverTag;
30+
31+
publicfunction__construct($argumentResolverService ='argument_resolver',$argumentValueResolverTag ='controller.argument_value_resolver')
32+
{
33+
$this->argumentResolverService =$argumentResolverService;
34+
$this->argumentValueResolverTag =$argumentValueResolverTag;
35+
}
36+
37+
publicfunctionprocess(ContainerBuilder$container)
38+
{
39+
if (!$container->hasDefinition($this->argumentResolverService)) {
40+
return;
41+
}
42+
43+
$container
44+
->getDefinition($this->argumentResolverService)
45+
->replaceArgument(1,newIteratorArgument($this->findAndSortTaggedServices($this->argumentValueResolverTag,$container)))
46+
;
47+
}
48+
}
Lines 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+
namespaceSymfony\Component\HttpKernel\Tests\DependencyInjection;
13+
14+
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\DependencyInjection\ContainerBuilder;
16+
useSymfony\Component\DependencyInjection\Definition;
17+
useSymfony\Component\DependencyInjection\Reference;
18+
useSymfony\Component\HttpKernel\Controller\ArgumentResolver;
19+
useSymfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
20+
21+
class ControllerArgumentValueResolverPassTestextends TestCase
22+
{
23+
publicfunctiontestServicesAreOrderedAccordingToPriority()
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+
newReference('n1'),
33+
newReference('n2'),
34+
newReference('n3'),
35+
);
36+
37+
$definition =newDefinition(ArgumentResolver::class,array(null,array()));
38+
$container =newContainerBuilder();
39+
$container->setDefinition('argument_resolver',$definition);
40+
41+
foreach ($servicesas$id =>list($tag)) {
42+
$container->register($id)->addTag('controller.argument_value_resolver',$tag);
43+
}
44+
45+
(newControllerArgumentValueResolverPass())->process($container);
46+
$this->assertEquals($expected,$definition->getArgument(1)->getValues());
47+
}
48+
49+
publicfunctiontestReturningEmptyArrayWhenNoService()
50+
{
51+
$definition =newDefinition(ArgumentResolver::class,array(null,array()));
52+
$container =newContainerBuilder();
53+
$container->setDefinition('argument_resolver',$definition);
54+
55+
(newControllerArgumentValueResolverPass())->process($container);
56+
$this->assertEquals(array(),$definition->getArgument(1)->getValues());
57+
}
58+
59+
publicfunctiontestNoArgumentResolver()
60+
{
61+
$container =newContainerBuilder();
62+
63+
(newControllerArgumentValueResolverPass())->process($container);
64+
65+
$this->assertFalse($container->hasDefinition('argument_resolver'));
66+
}
67+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp