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

Skip to content

Commit 3cf69f8

Browse files
committed
moving all component-related CompilerPass to their component
1 parent b226859 commit 3cf69f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+805
-467
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@
2222
/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php @lyrixx
2323
/src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php @lyrixx
2424
/src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php @lyrixx
25-
/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ValidateWorkflowsPass.php @lyrixx
26-
/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/WorkflowGuardListenerPass.php @lyrixx
2725
/src/Symfony/Component/Workflow/* @lyrixx

UPGRADE-4.2.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,29 @@ Serializer
6464

6565
* Relying on the default value (false) of the "as_collection" option is deprecated since 4.2.
6666
You should set it to false explicitly instead as true will be the default value in 5.0.
67+
* The `lazy` attribute on `doctrine.event_listener` tags was removed.
68+
Listeners are now lazy by default. So any `lazy` attributes can safely be removed from those tags.
69+
70+
FrameworkBundle
71+
---------------
72+
73+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass` has been deprecated.
74+
Use `Symfony\Component\Cache\DependencyInjection\CacheCollectorPass` instead.
75+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass` has been deprecated.
76+
Use `Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass` instead.
77+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass` has been deprecated.
78+
Use `Symfony\Component\Cache\DependencyInjection\CachePoolPass` instead.
79+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass` has been deprecated.
80+
Use `Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass` instead.
81+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass` has been deprecated.
82+
Use `Symfony\Component\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass` instead.
83+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass` has been deprecated.
84+
Use `Symfony\Component\ExpressionLanguage\DependencyInjection\AddExpressionLanguageProvidersPass` instead.
85+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass` has been deprecated.
86+
Use `Symfony\Component\Templating\DependencyInjection\TemplatingPass` instead.
87+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass` has been deprecated.
88+
Use `Symfony\Component\Translation\DependencyInjection\TranslationDataCollectorPass` instead.
89+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass` has been deprecated.
90+
Use `Symfony\Component\Translation\DependencyInjection\TranslationLoggingPass` instead.
91+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass` has been deprecated.
92+
Use `Symfony\Component\Workflow\DependencyInjection\WorkflowGuardListenerPass` instead.

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ CHANGELOG
77
* Allowed configuring taggable cache pools via a new `framework.cache.pools.tags` option (bool|service-id)
88
* Deprecated auto-injection of the container in AbstractController instances, register them as service subscribers instead
99
* Deprecated processing of services tagged `security.expression_language_provider` in favor of a new `AddExpressionLanguageProvidersPass` in SecurityBundle.
10+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CacheCollectorPass`. Use `Symfony\Component\Cache\DependencyInjection\CacheCollectorPass` instead.
11+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass` instead.
12+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolPass` instead.
13+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPrunerPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass` instead.
14+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass`. Use `Symfony\Component\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass` instead.
15+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass`. Use `Symfony\Component\ExpressionLanguage\DependencyInjection\AddExpressionLanguageProvidersPass` instead.
16+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass`. Use `Symfony\Component\Templating\DependencyInjection\TemplatingPass` instead.
17+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass`. Use `Symfony\Component\Translation\DependencyInjection\TranslationDataCollectorPass` instead.
18+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass`. Use `Symfony\Component\Translation\DependencyInjection\LoggingTranslatorPass` instead.
19+
* Deprecated `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass`. Use `Symfony\Component\Workflow\DependencyInjection\WorkflowGuardListenerPass` instead.
1020

1121
4.1.0
1222
-----

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

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

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

14-
use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass as SecurityExpressionLanguageProvidersPass;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17-
use Symfony\Component\DependencyInjection\Reference;
14+
@trigger_error(sprintf('%s is deprecated since version 4.2 and will be removed in 5.0. Use Symfony\Component\ExpressionLanguage\DependencyInjection\AddExpressionLanguageProvidersPass instead.', AddExpressionLanguageProvidersPass::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\ExpressionLanguage\DependencyInjection\AddExpressionLanguageProvidersPass as BaseAddExpressionLanguageProvidersPass;
1817

1918
/**
2019
* Registers the expression language providers.
2120
*
2221
* @author Fabien Potencier <[email protected]>
22+
*
23+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\ExpressionLanguage\DependencyInjection\AddExpressionLanguageProvidersPass instead.
2324
*/
24-
class AddExpressionLanguageProvidersPass implements CompilerPassInterface
25+
class AddExpressionLanguageProvidersPass extends BaseAddExpressionLanguageProvidersPass
2526
{
26-
private $handleSecurityLanguageProviders;
27-
28-
public function __construct(bool $handleSecurityLanguageProviders = true)
29-
{
30-
if ($handleSecurityLanguageProviders) {
31-
@trigger_error(sprintf('Registering services tagged "security.expression_language_provider" with "%s" is deprecated since Symfony 4.2, use the "%s" instead.', __CLASS__, SecurityExpressionLanguageProvidersPass::class), E_USER_DEPRECATED);
32-
}
33-
34-
$this->handleSecurityLanguageProviders = $handleSecurityLanguageProviders;
35-
}
36-
37-
/**
38-
* {@inheritdoc}
39-
*/
40-
public function process(ContainerBuilder $container)
41-
{
42-
// routing
43-
if ($container->has('router')) {
44-
$definition = $container->findDefinition('router');
45-
foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) {
46-
$definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id)));
47-
}
48-
}
49-
50-
// security
51-
if ($this->handleSecurityLanguageProviders && $container->has('security.expression_language')) {
52-
$definition = $container->findDefinition('security.expression_language');
53-
foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) {
54-
$definition->addMethodCall('registerProvider', array(new Reference($id)));
55-
}
56-
}
57-
}
5827
}

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
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
15-
use Symfony\Component\Cache\Adapter\TraceableAdapter;
16-
use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter;
17-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18-
use Symfony\Component\DependencyInjection\ContainerBuilder;
19-
use Symfony\Component\DependencyInjection\Definition;
20-
use Symfony\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+
use Symfony\Component\Cache\DependencyInjection\CacheCollectorPass as BaseCacheCollectorPass;
2117

2218
/**
2319
* Inject a data collector to all the cache services to be able to get detailed statistics.
2420
*
2521
* @author Tobias Nyholm <[email protected]>
22+
*
23+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CacheCollectorPass instead.
2624
*/
27-
class CacheCollectorPass implements CompilerPassInterface
25+
class CacheCollectorPass extends BaseCacheCollectorPass
2826
{
29-
/**
30-
* {@inheritdoc}
31-
*/
32-
public function process(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 = new Definition(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(new Reference($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, new Reference($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
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\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\CachePoolClearerPass instead.', CachePoolClearerPass::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass as BaseCachePoolClearerPass;
1717

1818
/**
1919
* @author Nicolas Grekas <[email protected]>
20+
*
21+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass instead.
2022
*/
21-
final class CachePoolClearerPass implements CompilerPassInterface
23+
class CachePoolClearerPass extends BaseCachePoolClearerPass
2224
{
23-
/**
24-
* {@inheritdoc}
25-
*/
26-
public function process(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] = new Reference($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
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\Cache\Adapter\AbstractAdapter;
15-
use Symfony\Component\Cache\Adapter\ArrayAdapter;
16-
use Symfony\Component\DependencyInjection\ChildDefinition;
17-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18-
use Symfony\Component\DependencyInjection\ContainerBuilder;
19-
use Symfony\Component\DependencyInjection\Definition;
20-
use Symfony\Component\DependencyInjection\Reference;
21-
use Symfony\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+
use Symfony\Component\Cache\DependencyInjection\CachePoolPass as BaseCachePoolPass;
2217

2318
/**
2419
* @author Nicolas Grekas <[email protected]>
20+
*
21+
* @deprecated since version 4.2, to be removed in 5.0. Use Symfony\Component\Cache\DependencyInjection\CachePoolPass instead.
2522
*/
26-
class CachePoolPass implements CompilerPassInterface
23+
class CachePoolPass extends BaseCachePoolPass
2724
{
28-
/**
29-
* {@inheritdoc}
30-
*/
31-
public function process(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 ($adapter instanceof 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'] = new Reference(static::getServiceProvider($container, $tags[0]['provider']));
76-
}
77-
$i = 0;
78-
foreach ($attributes as $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-
throw new InvalidArgumentException(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] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
96-
}
97-
98-
$pools[$name] = new Reference($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 ($clearers as $id => $pools) {
110-
$clearer = $container->getDefinition($id);
111-
if ($clearer instanceof 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-
private function getNamespace($seed, $id)
125-
{
126-
return substr(str_replace('/', '-', base64_encode(hash('sha256', $id.$seed, true))), 0, 10);
127-
}
128-
129-
/**
130-
* @internal
131-
*/
132-
public static function getServiceProvider(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 = new Definition(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
}

0 commit comments

Comments
 (0)