Skip to content

Commit 45741ad

Browse files
Olivier DolbeauNyholm
authored andcommitted
Deprecate a bunch of service aliases (#368)
1 parent 8a487aa commit 45741ad

20 files changed

+227
-167
lines changed

DependencyInjection/CompilerPass/EditInPlacePass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Translation\Bundle\Translator\EditInPlaceTranslator;
1819

1920
/**
2021
* @author Damien Alexandre <dalexandre@jolicode.com>
@@ -24,14 +25,11 @@ class EditInPlacePass implements CompilerPassInterface
2425
public function process(ContainerBuilder $container): void
2526
{
2627
/* @var Definition $def */
27-
if (!$container->hasDefinition('php_translator.edit_in_place.xtrans_html_translator')) {
28+
if (!$container->hasDefinition(EditInPlaceTranslator::class)) {
2829
return;
2930
}
3031

3132
// Replace the Twig Translator by a custom HTML one
32-
$container->getDefinition('twig.extension.trans')->replaceArgument(
33-
0,
34-
new Reference('php_translator.edit_in_place.xtrans_html_translator')
35-
);
33+
$container->getDefinition('twig.extension.trans')->replaceArgument(0, new Reference(EditInPlaceTranslator::class));
3634
}
3735
}

DependencyInjection/CompilerPass/ExtractorPass.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Translation\Extractor\Extractor;
1819

1920
/**
2021
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
@@ -32,12 +33,12 @@ public function process(ContainerBuilder $container): void
3233
*/
3334
private function getExtractors(ContainerBuilder $container): array
3435
{
35-
if (!$container->hasDefinition('php_translation.extractor')) {
36+
if (!$container->hasDefinition(Extractor::class)) {
3637
return [];
3738
}
3839

3940
/** @var Definition $def */
40-
$def = $container->getDefinition('php_translation.extractor');
41+
$def = $container->getDefinition(Extractor::class);
4142
$services = $container->findTaggedServiceIds('php_translation.extractor');
4243
$extractors = [];
4344
foreach ($services as $id => $tags) {

DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1616
use Symfony\Component\Config\Definition\ConfigurationInterface;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
use Translation\Bundle\EditInPlace\Activator;
1819

1920
/**
2021
* This is the class that validates and merges configuration from your app/config files.
@@ -199,7 +200,7 @@ private function addEditInPlaceNode(ArrayNodeDefinition $root): void
199200
->canBeEnabled()
200201
->children()
201202
->scalarNode('config_name')->defaultValue('default')->end()
202-
->scalarNode('activator')->cannotBeEmpty()->defaultValue('php_translation.edit_in_place.activator')->end()
203+
->scalarNode('activator')->cannotBeEmpty()->defaultValue(Activator::class)->end()
203204
->scalarNode('show_untranslatable')->defaultTrue()->end()
204205
->end()
205206
->end()

DependencyInjection/TranslationExtension.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@
2020
use Symfony\Component\DependencyInjection\Reference;
2121
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2222
use Symfony\Component\HttpKernel\Kernel;
23+
use Translation\Bundle\EventListener\AutoAddMissingTranslations;
24+
use Translation\Bundle\EventListener\EditInPlaceResponseListener;
2325
use Translation\Bundle\Model\Configuration as ConfigurationModel;
26+
use Translation\Bundle\Service\ConfigurationManager;
27+
use Translation\Bundle\Service\StorageManager;
2428
use Translation\Bundle\Service\StorageService;
29+
use Translation\Bundle\Translator\EditInPlaceTranslator;
30+
use Translation\Bundle\Twig\EditInPlaceExtension;
31+
use Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices;
2532

2633
/**
2734
* This is the class that loads and manages your bundle configuration.
@@ -43,7 +50,7 @@ public function load(array $configs, ContainerBuilder $container): void
4350
$loader->load('extractors.yaml');
4451

4552
// Add major version to extractor
46-
$container->getDefinition('php_translation.extractor.php.visitor.FormTypeChoices')
53+
$container->getDefinition(FormTypeChoices::class)
4754
->addMethodCall('setSymfonyMajorVersion', [Kernel::MAJOR_VERSION]);
4855

4956
$container->setParameter('php_translation.locales', $config['locales']);
@@ -70,7 +77,7 @@ public function load(array $configs, ContainerBuilder $container): void
7077

7178
if ($config['auto_add_missing_translations']['enabled']) {
7279
$loader->load('auto_add.yaml');
73-
$container->getDefinition('php_translator.auto_adder')
80+
$container->getDefinition(AutoAddMissingTranslations::class)
7481
->replaceArgument(0, new Reference('php_translation.storage.'.$config['auto_add_missing_translations']['config_name']));
7582
}
7683

@@ -79,10 +86,6 @@ public function load(array $configs, ContainerBuilder $container): void
7986
$this->enableFallbackAutoTranslator($container, $config);
8087
}
8188

82-
if ('test' === \getenv('ENV')) {
83-
$loader->load('services_test.yaml');
84-
}
85-
8689
$loader->load('console.yaml');
8790
}
8891

@@ -91,8 +94,8 @@ public function load(array $configs, ContainerBuilder $container): void
9194
*/
9295
private function handleConfigNode(ContainerBuilder $container, array $config): void
9396
{
94-
$storageManager = $container->getDefinition('php_translation.storage_manager');
95-
$configurationManager = $container->getDefinition('php_translation.configuration_manager');
97+
$storageManager = $container->getDefinition(StorageManager::class);
98+
$configurationManager = $container->getDefinition(ConfigurationManager::class);
9699
// $first will be the "default" configuration.
97100
$first = null;
98101
foreach ($config['configs'] as $name => &$c) {
@@ -179,15 +182,15 @@ private function enableEditInPlace(ContainerBuilder $container, array $config):
179182

180183
$activatorRef = new Reference($config['edit_in_place']['activator']);
181184

182-
$def = $container->getDefinition('php_translation.edit_in_place.response_listener');
185+
$def = $container->getDefinition(EditInPlaceResponseListener::class);
183186
$def->replaceArgument(0, $activatorRef);
184187
$def->replaceArgument(3, $name);
185188
$def->replaceArgument(4, $config['edit_in_place']['show_untranslatable']);
186189

187-
$def = $container->getDefinition('php_translator.edit_in_place.xtrans_html_translator');
190+
$def = $container->getDefinition(EditInPlaceTranslator::class);
188191
$def->replaceArgument(1, $activatorRef);
189192

190-
$def = $container->getDefinition('php_translation.edit_in_place.extension.trans');
193+
$def = $container->getDefinition(EditInPlaceExtension::class);
191194
$def->replaceArgument(2, $activatorRef);
192195
}
193196

Resources/config/auto_add.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
services:
2-
php_translator.auto_adder:
3-
class: Translation\Bundle\EventListener\AutoAddMissingTranslations
2+
Translation\Bundle\EventListener\AutoAddMissingTranslations:
43
arguments: [ ~, '@?translator.data_collector' ]
54
tags:
65
- { name: kernel.event_listener, event: kernel.terminate, method: onTerminate, priority: 10 }

Resources/config/auto_translation.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
services:
2-
php_translator.fallback_translator:
3-
class: Translation\Bundle\Translator\FallbackTranslator
2+
Translation\Bundle\Translator\FallbackTranslator:
43
public: false
54
decorates: 'translator'
65
decoration_priority: 10

Resources/config/console.yaml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
11
services:
2-
php_translator.console.delete_obsolete:
3-
class: Translation\Bundle\Command\DeleteObsoleteCommand
2+
Translation\Bundle\Command\DeleteObsoleteCommand:
43
public: true
54
arguments:
6-
- '@php_translation.storage_manager'
7-
- '@php_translation.configuration_manager'
8-
- '@php_translation.catalogue_manager'
9-
- '@php_translation.catalogue_fetcher'
5+
- '@Translation\Bundle\Service\StorageManager'
6+
- '@Translation\Bundle\Service\ConfigurationManager'
7+
- '@Translation\Bundle\Catalogue\CatalogueManager'
8+
- '@Translation\Bundle\Catalogue\CatalogueFetcher'
109
tags:
1110
- { name: console.command, command: translation:delete-obsolete}
1211

13-
php_translator.console.download:
14-
class: Translation\Bundle\Command\DownloadCommand
12+
Translation\Bundle\Command\DownloadCommand:
1513
public: true
1614
arguments:
17-
- '@php_translation.storage_manager'
18-
- '@php_translation.configuration_manager'
19-
- '@php_translation.cache_clearer'
15+
- '@Translation\Bundle\Service\StorageManager'
16+
- '@Translation\Bundle\Service\ConfigurationManager'
17+
- '@Translation\Bundle\Service\CacheClearer'
2018
tags:
2119
- { name: console.command, command: translation:download }
2220

23-
php_translator.console.extract:
24-
class: Translation\Bundle\Command\ExtractCommand
21+
Translation\Bundle\Command\ExtractCommand:
2522
public: true
2623
arguments:
27-
- '@php_translation.catalogue_fetcher'
28-
- '@php_translation.catalogue_writer'
29-
- '@php_translation.catalogue_counter'
30-
- '@php_translation.importer'
31-
- '@php_translation.configuration_manager'
24+
- '@Translation\Bundle\Catalogue\CatalogueFetcher'
25+
- '@Translation\Bundle\Catalogue\CatalogueWriter'
26+
- '@Translation\Bundle\Catalogue\CatalogueCounter'
27+
- '@Translation\Bundle\Service\Importer'
28+
- '@Translation\Bundle\Service\ConfigurationManager'
3229
tags:
3330
- { name: console.command, command: translation:extract }
3431

35-
php_translator.console.status:
36-
class: Translation\Bundle\Command\StatusCommand
32+
Translation\Bundle\Command\StatusCommand:
3733
public: true
3834
arguments:
39-
- '@php_translation.catalogue_counter'
40-
- '@php_translation.configuration_manager'
41-
- '@php_translation.catalogue_fetcher'
35+
- '@Translation\Bundle\Catalogue\CatalogueCounter'
36+
- '@Translation\Bundle\Service\ConfigurationManager'
37+
- '@Translation\Bundle\Catalogue\CatalogueFetcher'
4238
tags:
4339
- { name: console.command, command: translation:status }
4440

45-
php_translator.console.sync:
46-
class: Translation\Bundle\Command\SyncCommand
41+
Translation\Bundle\Command\SyncCommand:
4742
public: true
4843
arguments:
49-
- '@php_translation.storage_manager'
44+
- '@Translation\Bundle\Service\StorageManager'
5045
tags:
5146
- { name: console.command, command: translation:sync }
47+
48+
# To remove in next major release
49+
php_translator.console.delete_obsolete:
50+
parent: Translation\Bundle\Command\DeleteObsoleteCommand
51+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
52+
php_translator.console.download:
53+
parent: Translation\Bundle\Command\DownloadCommand
54+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
55+
php_translator.console.extract:
56+
parent: Translation\Bundle\Command\ExtractCommand
57+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
58+
php_translator.console.status:
59+
parent: Translation\Bundle\Command\StatusCommand
60+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
61+
php_translator.console.sync:
62+
parent: Translation\Bundle\Command\SyncCommand
63+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'

Resources/config/edit_in_place.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ services:
88
- '@Translation\Bundle\Service\CacheClearer'
99
- '@Symfony\Component\Validator\Validator\ValidatorInterface'
1010

11-
php_translation.edit_in_place.response_listener:
12-
class: Translation\Bundle\EventListener\EditInPlaceResponseListener
11+
Translation\Bundle\EventListener\EditInPlaceResponseListener:
1312
tags:
1413
- { name: 'kernel.event_listener', event: 'kernel.response', method: 'onKernelResponse' }
1514
arguments:
@@ -19,24 +18,35 @@ services:
1918
- ~
2019
- ~
2120

22-
php_translation.edit_in_place.activator:
23-
class: Translation\Bundle\EditInPlace\Activator
21+
Translation\Bundle\EditInPlace\Activator:
2422
arguments: ['@session']
2523
public: true
2624

27-
php_translator.edit_in_place.xtrans_html_translator:
28-
class: Translation\Bundle\Translator\EditInPlaceTranslator
25+
Translation\Bundle\Translator\EditInPlaceTranslator:
2926
arguments:
3027
- '@translator'
3128
- ~
3229
- '@request_stack'
3330

34-
php_translation.edit_in_place.extension.trans:
31+
Translation\Bundle\Twig\EditInPlaceExtension:
3532
public: false
36-
class: Translation\Bundle\Twig\EditInPlaceExtension
3733
arguments:
3834
- '@twig.extension.trans'
3935
- '@request_stack'
4036
- ~
4137
tags:
4238
- { name: 'twig.extension' }
39+
40+
# To remove in next major release
41+
php_translation.edit_in_place.response_listener:
42+
parent: Translation\Bundle\EventListener\EditInPlaceResponseListener
43+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
44+
php_translation.edit_in_place.activator:
45+
parent: Translation\Bundle\EditInPlace\Activator
46+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
47+
php_translator.edit_in_place.xtrans_html_translator:
48+
parent: Translation\Bundle\Translator\EditInPlaceTranslator
49+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
50+
php_translation.edit_in_place.extension.trans:
51+
parent: Translation\Bundle\Twig\EditInPlaceExtension
52+
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'

0 commit comments

Comments
 (0)