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

Appearance settings

Commit 32941f2

Browse filesBrowse files
committed
feature #36691 [FrameworkBundle] Deprecate some public services to private (fancyweb)
This PR was merged into the 5.2-dev branch. Discussion ---------- [FrameworkBundle] Deprecate some public services to private | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | - | License | MIT | Doc PR | - Now that we can deprecate public services to private, here is a first pass on the FWB. I think all those services don't need to be public, ie we never need to access them directly in Symfony's code (except in some tests that I had to modify accordingly). I think most of theses services needed to be public before we hooked the AbstractController with a service subscriber. There are definitely more of them that can be deprecated (ie: created workflows and state machines are public but don't need to be ?) but let's start with the easy ones. Commits ------- 87868ba [FrameworkBundle] Deprecate some public services to private
2 parents 5256323 + 87868ba commit 32941f2
Copy full SHA for 32941f2

19 files changed

+56
-6
lines changed

‎UPGRADE-5.2.md

Copy file name to clipboardExpand all lines: UPGRADE-5.2.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ DependencyInjection
66

77
* Deprecated `Definition::setPrivate()` and `Alias::setPrivate()`, use `setPublic()` instead
88

9+
FrameworkBundle
10+
---------------
11+
12+
* Deprecated the public `form.factory`, `form.type.file`, `translator`, `security.csrf.token_manager`, `serializer`,
13+
`cache_clearer`, `filesystem` and `validator` services to private.
14+
915
Mime
1016
----
1117

‎UPGRADE-6.0.md

Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ FrameworkBundle
5555
* `MicroKernelTrait::configureRoutes()` is now always called with a `RoutingConfigurator`
5656
* The "framework.router.utf8" configuration option defaults to `true`
5757
* Removed `session.attribute_bag` service and `session.flash_bag` service.
58+
* The `form.factory`, `form.type.file`, `translator`, `security.csrf.token_manager`, `serializer`,
59+
`cache_clearer`, `filesystem` and `validator` services are now private.
5860

5961
HttpFoundation
6062
--------------

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ CHANGELOG
66

77
* Added `framework.http_cache` configuration tree
88
* Added `framework.trusted_proxies` and `framework.trusted_headers` configuration options
9+
* Deprecated the public `form.factory`, `form.type.file`, `translator`, `security.csrf.token_manager`, `serializer`,
10+
`cache_clearer`, `filesystem` and `validator` services to private.
911

1012
5.1.0
1113
-----

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/form.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/form.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
->set('form.factory', FormFactory::class)
6262
->public()
6363
->args([service('form.registry')])
64+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
6465

6566
->alias(FormFactoryInterface::class, 'form.factory')
6667

@@ -103,6 +104,7 @@
103104
->public()
104105
->args([service('translator')->ignoreOnInvalid()])
105106
->tag('form.type')
107+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
106108

107109
->set('form.type.color', ColorType::class)
108110
->args([service('translator')->ignoreOnInvalid()])

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/identity_translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/identity_translator.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
$container->services()
1919
->set('translator', IdentityTranslator::class)
2020
->public()
21+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
2122
->alias(TranslatorInterface::class, 'translator')
2223

2324
->set('identity_translator', IdentityTranslator::class)

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/security_csrf.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/security_csrf.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
service('security.csrf.token_storage'),
3939
service('request_stack')->ignoreOnInvalid(),
4040
])
41+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
4142

4243
->alias(CsrfTokenManagerInterface::class, 'security.csrf.token_manager')
4344

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
->set('serializer', Serializer::class)
5656
->public()
5757
->args([[], []])
58+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
5859

5960
->alias(SerializerInterface::class, 'serializer')
6061
->alias(NormalizerInterface::class, 'serializer')

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
118118
->args([
119119
tagged_iterator('kernel.cache_clearer'),
120120
])
121+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
121122

122123
->set('kernel')
123124
->synthetic()
@@ -126,6 +127,7 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
126127

127128
->set('filesystem', Filesystem::class)
128129
->public()
130+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
129131
->alias(Filesystem::class, 'filesystem')
130132

131133
->set('file_locator', FileLocator::class)

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
->set('validator', ValidatorInterface::class)
3131
->public()
3232
->factory([service('validator.builder'), 'getValidator'])
33+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.2'])
3334
->alias(ValidatorInterface::class, 'validator')
3435

3536
->set('validator.builder', ValidatorBuilder::class)

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
'enable_annotations' => true,
88
],
99
]);
10+
11+
$container->setAlias('validator.alias', 'validator')->setPublic(true);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_annotations.xml
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<framework:config secret="s3cr3t">
1010
<framework:validation enabled="true" enable-annotations="true" />
1111
</framework:config>
12+
13+
<services>
14+
<service id="validator.alias" alias="validator" public="true" />
15+
</services>
1216
</container>

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_annotations.yml
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ framework:
33
validation:
44
enabled: true
55
enable_annotations: true
6+
7+
services:
8+
validator.alias:
9+
alias: validator
10+
public: true

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ public function testValidationService()
843843
{
844844
$container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false);
845845

846-
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator'));
846+
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator.alias'));
847847
}
848848

849849
public function testAnnotations()

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/BundlePathsTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/BundlePathsTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testBundleTwigTemplatesDir()
5353
public function testBundleTranslationsDir()
5454
{
5555
static::bootKernel(['test_case' => 'BundlePaths']);
56-
$translator = static::$container->get('translator');
56+
$translator = static::$container->get('translator.alias');
5757

5858
$this->assertSame('OK', $translator->trans('ok_label', [], 'legacy'));
5959
$this->assertSame('OK', $translator->trans('ok_label', [], 'modern'));
@@ -62,7 +62,7 @@ public function testBundleTranslationsDir()
6262
public function testBundleValidationConfigDir()
6363
{
6464
static::bootKernel(['test_case' => 'BundlePaths']);
65-
$validator = static::$container->get('validator');
65+
$validator = static::$container->get('validator.alias');
6666

6767
$this->assertTrue($validator->hasMetadataFor(LegacyPerson::class));
6868
$this->assertCount(1, $constraintViolationList = $validator->validate(new LegacyPerson('john', 5)));
@@ -76,7 +76,7 @@ public function testBundleValidationConfigDir()
7676
public function testBundleSerializationConfigDir()
7777
{
7878
static::bootKernel(['test_case' => 'BundlePaths']);
79-
$serializer = static::$container->get('serializer');
79+
$serializer = static::$container->get('serializer.alias');
8080

8181
$this->assertEquals(['full_name' => 'john', 'age' => 5], $serializer->normalize(new LegacyPerson('john', 5), 'json'));
8282
$this->assertEquals(['full_name' => 'john', 'age' => 5], $serializer->normalize(new ModernPerson('john', 5), 'json'));

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function doTestCachePools($options, $adapterClass)
9696
$pool2 = $container->get('cache.pool2');
9797
$pool2->save($item);
9898

99-
$container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir'));
99+
$container->get('cache_clearer.alias')->clear($container->getParameter('kernel.cache_dir'));
100100
$item = $pool1->getItem($key);
101101
$this->assertFalse($item->isHit());
102102

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testDeserializeArrayOfObject()
2020
{
2121
static::bootKernel(['test_case' => 'Serializer']);
2222

23-
$result = static::$container->get('serializer')->deserialize('{"bars": [{"id": 1}, {"id": 2}]}', Foo::class, 'json');
23+
$result = static::$container->get('serializer.alias')->deserialize('{"bars": [{"id": 1}, {"id": 2}]}', Foo::class, 'json');
2424

2525
$bar1 = new Bar();
2626
$bar1->id = 1;

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/BundlePaths/config.yml
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,15 @@ twig:
1212
services:
1313
twig.alias:
1414
alias: twig
15+
16+
validator.alias:
17+
alias: validator
18+
public: true
19+
20+
serializer.alias:
21+
alias: serializer
22+
public: true
23+
24+
translator.alias:
25+
alias: translator
1526
public: true

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ framework:
2424
cache.pool7:
2525
adapter: cache.pool4
2626
public: true
27+
28+
services:
29+
cache_clearer.alias:
30+
alias: cache_clearer
31+
public: true

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/config.yml
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ imports:
44
framework:
55
serializer: { enabled: true }
66
property_info: { enabled: true }
7+
8+
services:
9+
serializer.alias:
10+
alias: serializer
11+
public: true

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.