8000 feature #22620 [FrameworkBundle][HttpKernel] Move httpkernel pass (le… · symfony/symfony@3981f9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3981f9b

Browse files
committed
feature #22620 [FrameworkBundle][HttpKernel] Move httpkernel pass (lepiaf)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle][HttpKernel] Move httpkernel pass | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | part of #21284 | License | MIT | Doc PR | n/a Move addcachearmer, addcacheclearer compiler pass to httpkernel Commits ------- 83727c7 [FrameworkBundle][HttpKernel] Move addcachearmer, addcacheclearer compiler pass
2 parents f7bca74 + 83727c7 commit 3981f9b

File tree

13 files changed

+274
-46
lines changed

13 files changed

+274
-46
lines changed

UPGRADE-3.4.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ FrameworkBundle
3838
will be removed in 4.0. Use the `--prefix` option with an empty string as value
3939
instead (e.g. `--prefix=""`)
4040

41+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass`
42+
class has been deprecated and will be removed in 4.0. Use the
43+
`Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` class instead.
44+
45+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass`
46+
class has been deprecated and will be removed in 4.0. Use the
47+
`Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` class instead.
48+
4149
Process
4250
-------
4351

UPGRADE-4.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ FrameworkBundle
348348
* The `--no-prefix` option of the `translation:update` command has
349349
been removed.
350350

351+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass` class has been removed.
352+
Use the `Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` class instead.
353+
354+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass` class has been removed.
355+
Use the `Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` class instead.
356+
351357
HttpFoundation
352358
--------------
353359

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ CHANGELOG
1010
require symfony/stopwatch` in your `dev` environment.
1111
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
1212
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
13+
* Deprecated `AddCacheClearerPass`, use `Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` instead.
14+
* Deprecated `AddCacheWarmerPass`, use `Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` instead.
1315

1416
3.3.0
1517
-----

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

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

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

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

1818
/**
1919
* Registers the cache clearers.
2020
*
21+ F438
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseAddCacheClearerPass instead}.
22+
*
2123
* @author Dustin Dobervich <ddobervich@gmail.com>
2224
*/
23-
class AddCacheClearerPass implements CompilerPassInterface
25+
class AddCacheClearerPass extends BaseAddCacheClearerPass
2426
{
25-
/**
26-
* {@inheritdoc}
27-
*/
28-
public function process(ContainerBuilder $container)
29-
{
30-
if (!$container->hasDefinition('cache_clearer')) {
31-
return;
32-
}
33-
34-
$clearers = array();
35-
foreach ($container->findTaggedServiceIds('kernel.cache_clearer', true) as $id => $attributes) {
36-
$clearers[] = new Reference($id);
37-
}
38-
39-
$container->getDefinition('cache_clearer')->replaceArgument(0, $clearers);
40-
}
4127
}

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

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

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

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

1818
/**
1919
* Registers the cache warmers.
2020
*
21+
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseAddCacheWarmerPass instead}.
22+
*
2123
* @author Fabien Potencier <fabien@symfony.com>
2224
*/
23-
class AddCacheWarmerPass implements CompilerPassInterface
25+
class AddCacheWarmerPass extends BaseAddCacheWarmerPass
2426
{
25-
use PriorityTaggedServiceTrait;
26-
27-
/**
28-
* {@inheritdoc}
29-
*/
30-
public function process(ContainerBuilder $container)
31-
{
32-
if (!$container->hasDefinition('cache_warmer')) {
33-
return;
34-
}
35-
36-
$warmers = $this->findAndSortTaggedServices('kernel.cache_warmer', $container);
37-
38-
if (empty($warmers)) {
39-
return;
40-
}
41-
42-
$container->getDefinition('cache_warmer')->replaceArgument(0, $warmers);
43-
}
4427
}

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
2222
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
2323
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
24-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
25-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass;
2624
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
2725
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
2826
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
2927
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
3028
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
3129
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
3230
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
31+
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass;
32+
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass;
3333
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
3434
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
3535
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;

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

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

19+
/**
20+
* @group legacy
21+
*/
1922
class AddCacheWarmerPassTest extends TestCase
2023
{
2124
public function testThatCacheWarmersAreProcessedInPriorityOrder()

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/config": "~3.3|~4.0",
2525
"symfony/event-dispatcher": "^3.3.1|~4.0",
2626
"symfony/http-foundation": "~3.3|~4.0",
27-
"symfony/http-kernel": "~3.3|~4.0",
27+
"symfony/http-kernel": "~3.4|~4.0",
2828
"symfony/polyfill-mbstring": "~1.0",
2929
"symfony/filesystem": "~2.8|~3.0|~4.0",
3030
"symfony/finder": "~2.8|~3.0|~4.0",
@@ -66,6 +66,7 @@
6666
"symfony/asset": "<3.3",
6767
"symfony/console": "<3.3",
6868
"symfony/form": "<3.3",
69+
"symfony/http-kernel": "<3.4",
6970
"symfony/property-info": "<3.3",
7071
"symfony/serializer": "<3.3",
7172
"symfony/translation": "<3.2",

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* added `AddCacheClearerPass`
8+
* added `AddCacheWarmerPass`
9+
410
3.3.0
511
-----
612

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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\ContainerBuilder;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\Reference;
17+
18+
/**
19+
* Registers the cache clearers.
20+
*
21+
* @author Dustin Dobervich <ddobervich@gmail.com>
22+
*/
23+
class AddCacheClearerPass implements CompilerPassInterface
24+
{
25+
private $cacheClearerId;
26+
private $cacheClearerTag;
27+
28+
public function __construct($cacheClearerId = 'cache_clearer', $cacheClearerTag = 'kernel.cache_clearer')
29+
{
30+
$this->cacheClearerId = $cacheClearerId;
31+
$this->cacheClearerTag = $cacheClearerTag;
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function process(ContainerBuilder $container)
38+
{
39+
if (!$container->hasDefinition($this->cacheClearerId)) {
40+
return;
41+
}
42+
43+
$clearers = array();
44+
foreach ($container->findTaggedServiceIds($this->cacheClearerTag, true) as $id => $attributes) {
45+
$clearers[] = new Reference($id);
46+
}
47+
48+
$container->getDefinition($this->cacheClearerId)->replaceArgument(0, $clearers);
49+
}
50+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\Compiler\PriorityTaggedServiceTrait;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
18+
/**
19+
* Registers the cache warmers.
20+
*
21+
* @author Fabien Potencier <fabien@symfony.com>
22+
*/
23+
class AddCacheWarmerPass implements CompilerPassInterface
24+
{
25+
use PriorityTaggedServiceTrait;
26+
27+
private $cacheWarmerId;
28+
private $cacheWarmerTag;
29+
30+
public function __construct($cacheWarmerId = 'cache_warmer', $cacheWarmerTag = 'kernel.cache_warmer')
31+
{
32+
$this->cacheWarmerId = $cacheWarmerId;
33+
$this->cacheWarmerTag = $cacheWarmerTag;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function process(ContainerBuilder $container)
40+
{
41+
if (!$container->hasDefinition($this->cacheWarmerId)) {
42+
return;
43+
}
44+
45+
$warmers = $this->findAndSortTaggedServices($this->cacheWarmerTag, $container);
46+
47+
if (empty($warmers)) {
48+
return;
49+
}
50+
51+
$container->getDefinition($this->cacheWarmerId)->replaceArgument(0, $warmers);
52+
}
53+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\Reference;
17+
use Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass;
18+
19+
class AddCacheClearerPassTest extends TestCase
20+
{
21+
public function testThatCacheClearer()
22+
{
23+
$container = new ContainerBuilder();
24+
25+
$definition = $container->register('cache_clearer')->addArgument(null);
26+
$container->register('my_cache_clearer_service1')->addTag('kernel.cache_clearer');
27+
28+
$addCacheWarmerPass = new AddCacheClearerPass();
29+
$addCacheWarmerPass->process($container);
30+
31+
$expected = array(
32+
new Reference('my_cache_clearer_service1'),
33+
);
34+
$this->assertEquals($expected, $definition->getArgument(0));
35+
}
36+
37+
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheClearerDefinition()
38+
{
39+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
40+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
41+
42+
$container->expects($this->never())->method('findTaggedServiceIds');
43+
$container->expects($this->never())->method('getDefinition');
44+
$container->expects($this->atLeastOnce())
45+
->method('hasDefinition')
46+
->with('cache_clearer')
47+
->will($this->returnValue(false));
48+
$definition->expects($this->never())->method('replaceArgument');
49+
50+
$addCacheWarmerPass = new AddCacheClearerPass();
51+
$addCacheWarmerPass->process($container);
52+
}
53+
}

0 commit comments

Comments
 (0)
0