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

Commite619abd

Browse files
committed
moving Cache-related compiler pass from FrameworkBundle to Cache component
1 parentdf26fea commite619abd

18 files changed

+368
-253
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ CHANGELOG
88
* Allowed configuring PDO-based cache pools via a new`cache.adapter.pdo` abstract service
99
* Deprecated auto-injection of the container in AbstractController instances, register them as service subscribers instead
1010
* Deprecated processing of services tagged`security.expression_language_provider` in favor of a new`AddExpressionLanguageProvidersPass` in SecurityBundle.
11+
* Deprecated`Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass`. Use`Symfony\Component\Cache\DependencyInjection\CacheCollectorPass` instead.
12+
* Deprecated`Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass`. Use`Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass` instead.
13+
* Deprecated`Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass`. Use`Symfony\Component\Cache\DependencyInjection\CachePoolPass` instead.
14+
* Deprecated`Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass`. Use`Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass` instead.
1115

1216
4.1.0
1317
-----

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

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

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

14-
useSymfony\Component\Cache\Adapter\TagAwareAdapterInterface;
15-
useSymfony\Component\Cache\Adapter\TraceableAdapter;
16-
useSymfony\Component\Cache\Adapter\TraceableTagAwareAdapter;
17-
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18-
useSymfony\Component\DependencyInjection\ContainerBuilder;
19-
useSymfony\Component\DependencyInjection\Definition;
20-
useSymfony\Component\DependencyInjection\Reference;
14+
@trigger_error(sprintf('%s is deprecated since version 4.2 and will be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CacheCollectorPass instead.', CacheCollectorPass::class),E_USER_DEPRECATED);
15+
16+
useSymfony\Component\Cache\DependencyInjection\CacheCollectorPassasBaseCacheCollectorPass;
2117

2218
/**
2319
* Inject a data collector to all the cache services to be able to get detailed statistics.
2420
*
2521
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
22+
*
23+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CacheCollectorPass instead.
2624
*/
27-
class CacheCollectorPassimplements CompilerPassInterface
25+
class CacheCollectorPassextends BaseCacheCollectorPass
2826
{
29-
/**
30-
* {@inheritdoc}
31-
*/
32-
publicfunctionprocess(ContainerBuilder$container)
33-
{
34-
if (!$container->hasDefinition('data_collector.cache')) {
35-
return;
36-
}
37-
38-
$collectorDefinition =$container->getDefinition('data_collector.cache');
39-
foreach ($container->findTaggedServiceIds('cache.pool')as$id =>$attributes) {
40-
$definition =$container->getDefinition($id);
41-
if ($definition->isAbstract()) {
42-
continue;
43-
}
44-
45-
$recorder =newDefinition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class);
46-
$recorder->setTags($definition->getTags());
47-
$recorder->setPublic($definition->isPublic());
48-
$recorder->setArguments(array(newReference($innerId =$id.'.recorder_inner')));
49-
50-
$definition->setTags(array());
51-
$definition->setPublic(false);
52-
53-
$container->setDefinition($innerId,$definition);
54-
$container->setDefinition($id,$recorder);
55-
56-
// Tell the collector to add the new instance
57-
$collectorDefinition->addMethodCall('addInstance',array($id,newReference($id)));
58-
$collectorDefinition->setPublic(false);
59-
}
60-
}
6127
}

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

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

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

14-
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15-
useSymfony\Component\DependencyInjection\ContainerBuilder;
16-
useSymfony\Component\DependencyInjection\Reference;
14+
@trigger_error(sprintf('%s is deprecated since version 4.2 and will be removed in 5.0. UseSymfony\Component\Cache\DependencyInjection\CachePoolClearerPass instead.', CachePoolClearerPass::class),E_USER_DEPRECATED);
15+
16+
useSymfony\Component\Cache\DependencyInjection\CachePoolClearerPassasBaseCachePoolClearerPass;
1717

1818
/**
1919
* @author Nicolas Grekas <p@tchwork.com>
20+
*
21+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass instead.
2022
*/
21-
finalclass CachePoolClearerPassimplements CompilerPassInterface
23+
class CachePoolClearerPassextends BaseCachePoolClearerPass
2224
{
23-
/**
24-
* {@inheritdoc}
25-
*/
26-
publicfunctionprocess(ContainerBuilder$container)
27-
{
28-
$container->getParameterBag()->remove('cache.prefix.seed');
29-
30-
foreach ($container->findTaggedServiceIds('cache.pool.clearer')as$id =>$attr) {
31-
$clearer =$container->getDefinition($id);
32-
$pools =array();
33-
foreach ($clearer->getArgument(0)as$name =>$ref) {
34-
if ($container->hasDefinition($ref)) {
35-
$pools[$name] =newReference($ref);
36-
}
37-
}
38-
$clearer->replaceArgument(0,$pools);
39-
}
40-
}
4125
}

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

Lines changed: 6 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -11,140 +11,15 @@
1111

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

14-
useSymfony\Component\Cache\Adapter\AbstractAdapter;
15-
useSymfony\Component\Cache\Adapter\ArrayAdapter;
16-
useSymfony\Component\DependencyInjection\ChildDefinition;
17-
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18-
useSymfony\Component\DependencyInjection\ContainerBuilder;
19-
useSymfony\Component\DependencyInjection\Definition;
20-
useSymfony\Component\DependencyInjection\Reference;
21-
useSymfony\Component\DependencyInjection\Exception\InvalidArgumentException;
14+
@trigger_error(sprintf('%s is deprecated since version 4.2 and will be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolPass instead.', CachePoolPass::class),E_USER_DEPRECATED);
15+
16+
useSymfony\Component\Cache\DependencyInjection\CachePoolPassasBaseCachePoolPass;
2217

2318
/**
2419
* @author Nicolas Grekas <p@tchwork.com>
20+
*
21+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolPass instead.
2522
*/
26-
class CachePoolPassimplements CompilerPassInterface
23+
class CachePoolPassextends BaseCachePoolPass
2724
{
28-
/**
29-
* {@inheritdoc}
30-
*/
31-
publicfunctionprocess(ContainerBuilder$container)
32-
{
33-
if ($container->hasParameter('cache.prefix.seed')) {
34-
$seed ='.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
35-
}else {
36-
$seed ='_'.$container->getParameter('kernel.root_dir');
37-
}
38-
$seed .='.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment');
39-
40-
$pools =array();
41-
$clearers =array();
42-
$attributes =array(
43-
'provider',
44-
'name',
45-
'namespace',
46-
'default_lifetime',
47-
'reset',
48-
);
49-
foreach ($container->findTaggedServiceIds('cache.pool')as$id =>$tags) {
50-
$adapter =$pool =$container->getDefinition($id);
51-
if ($pool->isAbstract()) {
52-
continue;
53-
}
54-
while ($adapterinstanceof ChildDefinition) {
55-
$adapter =$container->findDefinition($adapter->getParent());
56-
if ($t =$adapter->getTag('cache.pool')) {
57-
$tags[0] +=$t[0];
58-
}
59-
}
60-
$name =$tags[0]['name'] ??$id;
61-
if (!isset($tags[0]['namespace'])) {
62-
$tags[0]['namespace'] =$this->getNamespace($seed,$name);
63-
}
64-
if (isset($tags[0]['clearer'])) {
65-
$clearer =$tags[0]['clearer'];
66-
while ($container->hasAlias($clearer)) {
67-
$clearer = (string)$container->getAlias($clearer);
68-
}
69-
}else {
70-
$clearer =null;
71-
}
72-
unset($tags[0]['clearer'],$tags[0]['name']);
73-
74-
if (isset($tags[0]['provider'])) {
75-
$tags[0]['provider'] =newReference(static::getServiceProvider($container,$tags[0]['provider']));
76-
}
77-
$i =0;
78-
foreach ($attributesas$attr) {
79-
if (!isset($tags[0][$attr])) {
80-
// no-op
81-
}elseif ('reset' ===$attr) {
82-
if ($tags[0][$attr]) {
83-
$pool->addTag('kernel.reset',array('method' =>$tags[0][$attr]));
84-
}
85-
}elseif ('namespace' !==$attr || ArrayAdapter::class !==$adapter->getClass()) {
86-
$pool->replaceArgument($i++,$tags[0][$attr]);
87-
}
88-
unset($tags[0][$attr]);
89-
}
90-
if (!empty($tags[0])) {
91-
thrownewInvalidArgumentException(sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "clearer", "provider", "name", "namespace", "default_lifetime" and "reset", found "%s".',$id,implode('", "',array_keys($tags[0]))));
92-
}
93-
94-
if (null !==$clearer) {
95-
$clearers[$clearer][$name] =newReference($id,$container::IGNORE_ON_UNINITIALIZED_REFERENCE);
96-
}
97-
98-
$pools[$name] =newReference($id,$container::IGNORE_ON_UNINITIALIZED_REFERENCE);
99-
}
100-
101-
$clearer ='cache.global_clearer';
102-
while ($container->hasAlias($clearer)) {
103-
$clearer = (string)$container->getAlias($clearer);
104-
}
105-
if ($container->hasDefinition($clearer)) {
106-
$clearers['cache.global_clearer'] =$pools;
107-
}
108-
109-
foreach ($clearersas$id =>$pools) {
110-
$clearer =$container->getDefinition($id);
111-
if ($clearerinstanceof ChildDefinition) {
112-
$clearer->replaceArgument(0,$pools);
113-
}else {
114-
$clearer->setArgument(0,$pools);
115-
}
116-
$clearer->addTag('cache.pool.clearer');
117-
118-
if ('cache.system_clearer' ===$id) {
119-
$clearer->addTag('kernel.cache_clearer');
120-
}
121-
}
122-
}
123-
124-
privatefunctiongetNamespace($seed,$id)
125-
{
126-
returnsubstr(str_replace('/','-',base64_encode(hash('sha256',$id.$seed,true))),0,10);
127-
}
128-
129-
/**
130-
* @internal
131-
*/
132-
publicstaticfunctiongetServiceProvider(ContainerBuilder$container,$name)
133-
{
134-
$container->resolveEnvPlaceholders($name,null,$usedEnvs);
135-
136-
if ($usedEnvs ||preg_match('#^[a-z]++://#',$name)) {
137-
$dsn =$name;
138-
139-
if (!$container->hasDefinition($name ='.cache_connection.'.ContainerBuilder::hash($dsn))) {
140-
$definition =newDefinition(AbstractAdapter::class);
141-
$definition->setPublic(false);
142-
$definition->setFactory(array(AbstractAdapter::class,'createConnection'));
143-
$definition->setArguments(array($dsn,array('lazy' =>true)));
144-
$container->setDefinition($name,$definition);
145-
}
146-
}
147-
148-
return$name;
149-
}
15025
}

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

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,15 @@
1111

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

14-
useSymfony\Component\Cache\PruneableInterface;
15-
useSymfony\Component\DependencyInjection\Argument\IteratorArgument;
16-
useSymfony\Component\DependencyInjection\ContainerBuilder;
17-
useSymfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18-
useSymfony\Component\DependencyInjection\Exception\InvalidArgumentException;
19-
useSymfony\Component\DependencyInjection\Reference;
14+
@trigger_error(sprintf('%s is deprecated since version 4.2 and will be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass instead.', CachePoolPrunerPass::class),E_USER_DEPRECATED);
15+
16+
useSymfony\Component\Cache\DependencyInjection\CachePoolPrunerPassasBaseCachePoolPrunerPass;
2017

2118
/**
2219
* @author Rob Frawley 2nd <rmf@src.run>
20+
*
21+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass instead.
2322
*/
24-
class CachePoolPrunerPassimplements CompilerPassInterface
23+
class CachePoolPrunerPassextends BaseCachePoolPrunerPass
2524
{
26-
private$cacheCommandServiceId;
27-
private$cachePoolTag;
28-
29-
publicfunction__construct(string$cacheCommandServiceId ='console.command.cache_pool_prune',string$cachePoolTag ='cache.pool')
30-
{
31-
$this->cacheCommandServiceId =$cacheCommandServiceId;
32-
$this->cachePoolTag =$cachePoolTag;
33-
}
34-
35-
/**
36-
* {@inheritdoc}
37-
*/
38-
publicfunctionprocess(ContainerBuilder$container)
39-
{
40-
if (!$container->hasDefinition($this->cacheCommandServiceId)) {
41-
return;
42-
}
43-
44-
$services =array();
45-
46-
foreach ($container->findTaggedServiceIds($this->cachePoolTag)as$id =>$tags) {
47-
$class =$container->getParameterBag()->resolveValue($container->getDefinition($id)->getClass());
48-
49-
if (!$reflection =$container->getReflectionClass($class)) {
50-
thrownewInvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.',$class,$id));
51-
}
52-
53-
if ($reflection->implementsInterface(PruneableInterface::class)) {
54-
$services[$id] =newReference($id);
55-
}
56-
}
57-
58-
$container->getDefinition($this->cacheCommandServiceId)->replaceArgument(0,newIteratorArgument($services));
59-
}
6025
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
useSymfony\Component\Cache\Adapter\AdapterInterface;
2525
useSymfony\Component\Cache\Adapter\ArrayAdapter;
2626
useSymfony\Component\Cache\Adapter\TagAwareAdapter;
27+
useSymfony\Component\Cache\DependencyInjection\CachePoolPass;
2728
useSymfony\Component\Cache\Marshaller\DefaultMarshaller;
2829
useSymfony\Component\Cache\ResettableInterface;
2930
useSymfony\Component\Config\FileLocator;
@@ -1560,7 +1561,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
15601561
}
15611562
foreach (array('doctrine','psr6','redis','memcached','pdo')as$name) {
15621563
if (isset($config[$name ='default_'.$name.'_provider'])) {
1563-
$container->setAlias('cache.'.$name,newAlias(Compiler\CachePoolPass::getServiceProvider($container,$config[$name]),false));
1564+
$container->setAlias('cache.'.$name,newAlias(CachePoolPass::getServiceProvider($container,$config[$name]),false));
15641565
}
15651566
}
15661567
foreach (array('app','system')as$name) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313

1414
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
1515
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass;
16-
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass;
17-
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
18-
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass;
19-
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass;
2016
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2117
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
2218
useSymfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
@@ -53,6 +49,10 @@
5349
useSymfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
5450
useSymfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass;
5551
useSymfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass;
52+
useSymfony\Component\Cache\DependencyInjection\CacheCollectorPass;
53+
useSymfony\Component\Cache\DependencyInjection\CachePoolPass;
54+
useSymfony\Component\Cache\DependencyInjection\CachePoolClearerPass;
55+
useSymfony\Component\Cache\DependencyInjection\CachePoolPrunerPass;
5656

5757
/**
5858
* Bundle.

‎src/Symfony/Bundle/FrameworkBundle/composer.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php":"^7.1.3",
2020
"ext-xml":"*",
21-
"symfony/cache":"~3.4|~4.0",
21+
"symfony/cache":"~4.2",
2222
"symfony/dependency-injection":"^4.2",
2323
"symfony/config":"~4.2",
2424
"symfony/event-dispatcher":"^4.1",
@@ -73,7 +73,8 @@
7373
"symfony/translation":"<3.4",
7474
"symfony/twig-bridge":"<4.1.1",
7575
"symfony/validator":"<4.1",
76-
"symfony/workflow":"<4.1"
76+
"symfony/workflow":"<4.1",
77+
"symfony/cache":"<4.2"
7778
},
7879
"suggest": {
7980
"ext-apcu":"For best performance of the system caches",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ CHANGELOG
1313
* deprecated`CacheItem::getPreviousTags()`, use`CacheItem::getMetadata()` instead
1414
* deprecated the`AbstractAdapter::createSystemCache()` method
1515
* deprecated the`AbstractAdapter::unserialize()` and`AbstractCache::unserialize()` methods
16+
* added`CacheCollectorPass` (originally in FrameworkBundle)
17+
* added`CachePoolClearerPass` (originally in FrameworkBundle)
18+
* added`CachePoolPass` (originally in FrameworkBundle)
19+
* added`CachePoolPrunerPass` (originally in FrameworkBundle)
1620

1721
3.4.0
1822
-----

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp