Move ConfigCachePass from FrameworkBundle to Config
This commit is contained in:
parent
924c1f06bf
commit
bce445f452
@ -79,6 +79,11 @@ FrameworkBundle
|
|||||||
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
|
deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
|
||||||
class instead.
|
class instead.
|
||||||
|
|
||||||
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass` class has been
|
||||||
|
deprecated and will be removed in 4.0. Use `Symfony\Component\Config\DependencyInjection\ConfigCachePass`
|
||||||
|
class instead.
|
||||||
|
|
||||||
|
|
||||||
HttpKernel
|
HttpKernel
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -195,6 +195,10 @@ FrameworkBundle
|
|||||||
removed. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
|
removed. Use the `Symfony\Component\HttpKernel\EventListener\TestSessionListener`
|
||||||
class instead.
|
class instead.
|
||||||
|
|
||||||
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass` class has been removed.
|
||||||
|
Use `Symfony\Component\Config\DependencyInjection\ConfigCachePass` class instead.
|
||||||
|
|
||||||
|
|
||||||
HttpFoundation
|
HttpFoundation
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ CHANGELOG
|
|||||||
* Deprecated `FormPass`, use `Symfony\Component\Form\DependencyInjection\FormPass` instead
|
* Deprecated `FormPass`, use `Symfony\Component\Form\DependencyInjection\FormPass` instead
|
||||||
* Deprecated `SessionListener`
|
* Deprecated `SessionListener`
|
||||||
* Deprecated `TestSessionListener`
|
* Deprecated `TestSessionListener`
|
||||||
|
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass`.
|
||||||
|
Use `Symfony\Component\Console\DependencyInjection\ConfigCachePass` instead.
|
||||||
|
|
||||||
3.2.0
|
3.2.0
|
||||||
-----
|
-----
|
||||||
|
@ -11,28 +11,18 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\Config\DependencyInjection\ConfigCachePass as BaseConfigCachePass;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority.
|
* Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority.
|
||||||
*
|
*
|
||||||
|
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseConfigCachePass} instead.
|
||||||
|
*
|
||||||
* @author Matthias Pigulla <mp@webfactory.de>
|
* @author Matthias Pigulla <mp@webfactory.de>
|
||||||
* @author Benjamin Klotz <bk@webfactory.de>
|
* @author Benjamin Klotz <bk@webfactory.de>
|
||||||
*/
|
*/
|
||||||
class ConfigCachePass implements CompilerPassInterface
|
class ConfigCachePass extends BaseConfigCachePass
|
||||||
{
|
{
|
||||||
use PriorityTaggedServiceTrait;
|
|
||||||
|
|
||||||
public function process(ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
$resourceCheckers = $this->findAndSortTaggedServices('config_cache.resource_checker', $container);
|
|
||||||
|
|
||||||
if (empty($resourceCheckers)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$container->getDefinition('config_cache_factory')->replaceArgument(0, $resourceCheckers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDum
|
|||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass;
|
||||||
|
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
||||||
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
||||||
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
|
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
|
||||||
use Symfony\Component\Debug\ErrorHandler;
|
use Symfony\Component\Debug\ErrorHandler;
|
||||||
@ -108,7 +108,7 @@ class FrameworkBundle extends Bundle
|
|||||||
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
|
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
|
||||||
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
|
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
|
||||||
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING, -32);
|
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING, -32);
|
||||||
$container->addCompilerPass(new ConfigCachePass());
|
$this->addCompilerPassIfExists($container, ConfigCachePass::class);
|
||||||
$container->addCompilerPass(new CacheCollectorPass());
|
$container->addCompilerPass(new CacheCollectorPass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
class ConfigCachePassTest extends TestCase
|
class ConfigCachePassTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testThatCheckersAreProcessedInPriorityOrder()
|
public function testThatCheckersAreProcessedInPriorityOrder()
|
||||||
|
@ -7,6 +7,7 @@ CHANGELOG
|
|||||||
* added `ReflectionClassResource` class
|
* added `ReflectionClassResource` class
|
||||||
* added second `$exists` constructor argument to `ClassExistenceResource`
|
* added second `$exists` constructor argument to `ClassExistenceResource`
|
||||||
* made `ClassExistenceResource` work with interfaces and traits
|
* made `ClassExistenceResource` work with interfaces and traits
|
||||||
|
* added `ConfigCachePass` (originally in FrameworkBundle)
|
||||||
|
|
||||||
3.0.0
|
3.0.0
|
||||||
-----
|
-----
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Config\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds services tagged config_cache.resource_checker to the config_cache_factory service, ordering them by priority.
|
||||||
|
*
|
||||||
|
* @author Matthias Pigulla <mp@webfactory.de>
|
||||||
|
* @author Benjamin Klotz <bk@webfactory.de>
|
||||||
|
*/
|
||||||
|
class ConfigCachePass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
use PriorityTaggedServiceTrait;
|
||||||
|
|
||||||
|
private $factoryServiceId;
|
||||||
|
private $resourceCheckerTag;
|
||||||
|
|
||||||
|
public function __construct($factoryServiceId = 'config_cache_factory', $resourceCheckerTag = 'config_cache.resource_checker')
|
||||||
|
{
|
||||||
|
$this->factoryServiceId = $factoryServiceId;
|
||||||
|
$this->resourceCheckerTag = $resourceCheckerTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$resourceCheckers = $this->findAndSortTaggedServices($this->resourceCheckerTag, $container);
|
||||||
|
|
||||||
|
if (empty($resourceCheckers)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container->getDefinition($this->factoryServiceId)->replaceArgument(0, $resourceCheckers);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Config\Tests\DependencyInjection;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
|
||||||
|
|
||||||
|
class ConfigCachePassTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testThatCheckersAreProcessedInPriorityOrder()
|
||||||
|
{
|
||||||
|
$services = array(
|
||||||
|
'checker_2' => array(0 => array('priority' => 100)),
|
||||||
|
'checker_1' => array(0 => array('priority' => 200)),
|
||||||
|
'checker_3' => array(0 => array()),
|
||||||
|
);
|
||||||
|
|
||||||
|
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
|
||||||
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
|
||||||
|
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('findTaggedServiceIds')
|
||||||
|
->will($this->returnValue($services));
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('getDefinition')
|
||||||
|
->with('config_cache_factory')
|
||||||
|
->will($this->returnValue($definition));
|
||||||
|
|
||||||
|
$definition->expects($this->once())
|
||||||
|
->method('replaceArgument')
|
||||||
|
->with(0, array(
|
||||||
|
new Reference('checker_1'),
|
||||||
|
new Reference('checker_2'),
|
||||||
|
new Reference('checker_3'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$pass = new ConfigCachePass();
|
||||||
|
$pass->process($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThatCheckersCanBeMissing()
|
||||||
|
{
|
||||||
|
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
|
||||||
|
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('findTaggedServiceIds')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$pass = new ConfigCachePass();
|
||||||
|
$pass->process($container);
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,11 @@
|
|||||||
"symfony/filesystem": "~2.8|~3.0"
|
"symfony/filesystem": "~2.8|~3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/yaml": "~3.0"
|
"symfony/yaml": "~3.0",
|
||||||
|
"symfony/dependency-injection": "~3.2"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/dependency-injection": "<3.2"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/yaml": "To use the yaml reference dumper"
|
"symfony/yaml": "To use the yaml reference dumper"
|
||||||
|
Reference in New Issue
Block a user