Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bce445f

Browse files
committed
Move ConfigCachePass from FrameworkBundle to Config
1 parent 924c1f0 commit bce445f

File tree

10 files changed

+137
-19
lines changed

10 files changed

+137
-19
lines changed

UPGRADE-3.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ FrameworkBundle
7979
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
8080
class instead.
8181

82+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass` class has been
83+
deprecated and will be removed in 4.0. Use `Symfony\Component\Config\DependencyInjection\ConfigCachePass`
84+
class instead.
85+
86+
8287
HttpKernel
8388
-----------
8489

UPGRADE-4.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ FrameworkBundle
195195
removed. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
196196
class instead.
197197

198+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass` class has been removed.
199+
Use `Symfony\Component\Config\DependencyInjection\ConfigCachePass` class instead.
200+
201+
198202
HttpFoundation
199203
---------------
200204

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ CHANGELOG
1717
* Deprecated `FormPass`, use `Symfony\Component\Form\DependencyInjection\FormPass` instead
1818
* Deprecated `SessionListener`
1919
* Deprecated `TestSessionListener`
20+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass`.
21+
Use `Symfony\Component\Console\DependencyInjection\ConfigCachePass` instead.
2022

2123
3.2.0
2224
-----

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

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

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

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

1818
/**
1919
* Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority.
2020
*
21+
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseConfigCachePass} instead.
22+
*
2123
* @author Matthias Pigulla <[email protected]>
2224
* @author Benjamin Klotz <[email protected]>
2325
*/
24-
class ConfigCachePass implements CompilerPassInterface
26+
class ConfigCachePass extends BaseConfigCachePass
2527
{
26-
use PriorityTaggedServiceTrait;
27-
28-
public function process(ContainerBuilder $container)
29-
{
30-
$resourceCheckers = $this->findAndSortTaggedServices('config_cache.resource_checker', $container);
31-
32-
if (empty($resourceCheckers)) {
33-
return;
34-
}
35-
36-
$container->getDefinition('config_cache_factory')->replaceArgument(0, $resourceCheckers);
37-
}
3828
}

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
3535
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
3636
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
37-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
3837
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass;
38+
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
3939
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
4040
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
4141
use Symfony\Component\Debug\ErrorHandler;
@@ -108,7 +108,7 @@ public function build(ContainerBuilder $container)
108108
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
109109
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
110110
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING, -32);
111-
$container->addCompilerPass(new ConfigCachePass());
111+
$this->addCompilerPassIfExists($container, ConfigCachePass::class);
112112
$container->addCompilerPass(new CacheCollectorPass());
113113
}
114114
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\DependencyInjection\Reference;
1616
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
1717

18+
/**
19+
* @group legacy
20+
*/
1821
class ConfigCachePassTest extends TestCase
1922
{
2023
public function testThatCheckersAreProcessedInPriorityOrder()

src/Symfony/Component/Config/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* added `ReflectionClassResource` class
88
* added second `$exists` constructor argument to `ClassExistenceResource`
99
* made `ClassExistenceResource` work with interfaces and traits
10+
* added `ConfigCachePass` (originally in FrameworkBundle)
1011

1112
3.0.0
1213
-----
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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\Config\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
18+
/**
19+
* Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority.
20+
*
21+
* @author Matthias Pigulla <[email protected]>
22+
* @author Benjamin Klotz <[email protected]>
23+
*/
24+
class ConfigCachePass implements CompilerPassInterface
25+
{
26+
use PriorityTaggedServiceTrait;
27+
28+
private $factoryServiceId;
29+
private $resourceCheckerTag;
30+
31+
public function __construct($factoryServiceId = 'config_cache_factory', $resourceCheckerTag = 'config_cache.resource_checker')
32+
{
33+
$this->factoryServiceId = $factoryServiceId;
34+
$this->resourceCheckerTag = $resourceCheckerTag;
35+
}
36+
37+
public function process(ContainerBuilder $container)
38+
{
39+
$resourceCheckers = $this->findAndSortTaggedServices($this->resourceCheckerTag, $container);
40+
41+
if (empty($resourceCheckers)) {
42+
return;
43+
}
44+
45+
$container->getDefinition($this->factoryServiceId)->replaceArgument(0, $resourceCheckers);
46+
}
47+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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\Config\Tests\DependencyInjection;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\Reference;
16+
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
17+
18+
class ConfigCachePassTest extends TestCase
19+
{
20+
public function testThatCheckersAreProcessedInPriorityOrder()
21+
{
22+
$services = array(
23+
'checker_2' => array(0 => array('priority' => 100)),
24+
'checker_1' => array(0 => array('priority' => 200)),
25+
'checker_3' => array(0 => array()),
26+
);
27+
28+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
29+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
30+
31+
$container->expects($this->atLeastOnce())
32+
->method('findTaggedServiceIds')
33+
->will($this->returnValue($services));
34+
$container->expects($this->atLeastOnce())
35+
->method('getDefinition')
36+
->with('config_cache_factory')
37+
->will($this->returnValue($definition));
38+
39+
$definition->expects($this->once())
40+
->method('replaceArgument')
41+
->with(0, array(
42+
new Reference('checker_1'),
43+
new Reference('checker_2'),
44+
new Reference('checker_3'),
45+
));
46+
47+
$pass = new ConfigCachePass();
48+
$pass->process($container);
49+
}
50+
51+
public function testThatCheckersCanBeMissing()
52+
{
53+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
54+
55+
$container->expects($this->atLeastOnce())
56+
->method('findTaggedServiceIds')
57+
->will($this->returnValue(array()));
58+
59+
$pass = new ConfigCachePass();
60+
$pass->process($container);
61+
}
62+
}

src/Symfony/Component/Config/composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
"symfony/filesystem": "~2.8|~3.0"
2121
},
2222
"require-dev": {
23-
"symfony/yaml": "~3.0"
23+
"symfony/yaml": "~3.0",
24+
"symfony/dependency-injection": "~3.2"
25+
},
26+
"conflict": {
27+
"symfony/dependency-injection": "<3.2"
2428
},
2529
"suggest": {
2630
"symfony/yaml": "To use the yaml reference dumper"

0 commit comments

Comments
 (0)