From 3a52ac897229fa5b68651e61ffb21d2ef2cee94c Mon Sep 17 00:00:00 2001 From: Olivier Dolbeau Date: Thu, 26 Dec 2019 16:21:09 +0100 Subject: [PATCH] Deprecate a bunch of service aliases --- .../CompilerPass/EditInPlacePass.php | 8 +- .../CompilerPass/ExtractorPass.php | 5 +- DependencyInjection/Configuration.php | 3 +- DependencyInjection/TranslationExtension.php | 25 ++--- Resources/config/auto_add.yaml | 3 +- Resources/config/auto_translation.yaml | 3 +- Resources/config/console.yaml | 64 +++++++------ Resources/config/edit_in_place.yaml | 26 ++++-- Resources/config/extractors.yaml | 92 ++++++++++++------ Resources/config/services.yaml | 93 +++++++++++-------- Resources/config/services_test.yaml | 16 ---- Tests/Functional/BundleInitializationTest.php | 18 ++-- .../Catalogue/CatalogueFetcherTest.php | 2 +- .../Functional/Command/ExtractCommandTest.php | 9 +- .../Functional/Command/StatusCommandTest.php | 3 +- Tests/Functional/Command/SyncCommandTest.php | 3 +- .../Functional/Controller/EditInPlaceTest.php | 5 +- .../CompilerPass/EditInPlacePassTest.php | 5 +- .../CompilerPass/ExtractorPassTest.php | 5 +- .../TranslationExtensionTest.php | 6 +- 20 files changed, 227 insertions(+), 167 deletions(-) delete mode 100644 Resources/config/services_test.yaml diff --git a/DependencyInjection/CompilerPass/EditInPlacePass.php b/DependencyInjection/CompilerPass/EditInPlacePass.php index 1d4b9517..71dc6a30 100644 --- a/DependencyInjection/CompilerPass/EditInPlacePass.php +++ b/DependencyInjection/CompilerPass/EditInPlacePass.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +use Translation\Bundle\Translator\EditInPlaceTranslator; /** * @author Damien Alexandre @@ -24,14 +25,11 @@ class EditInPlacePass implements CompilerPassInterface public function process(ContainerBuilder $container): void { /* @var Definition $def */ - if (!$container->hasDefinition('php_translator.edit_in_place.xtrans_html_translator')) { + if (!$container->hasDefinition(EditInPlaceTranslator::class)) { return; } // Replace the Twig Translator by a custom HTML one - $container->getDefinition('twig.extension.trans')->replaceArgument( - 0, - new Reference('php_translator.edit_in_place.xtrans_html_translator') - ); + $container->getDefinition('twig.extension.trans')->replaceArgument(0, new Reference(EditInPlaceTranslator::class)); } } diff --git a/DependencyInjection/CompilerPass/ExtractorPass.php b/DependencyInjection/CompilerPass/ExtractorPass.php index 030f0f3f..7e81566a 100644 --- a/DependencyInjection/CompilerPass/ExtractorPass.php +++ b/DependencyInjection/CompilerPass/ExtractorPass.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +use Translation\Extractor\Extractor; /** * @author Tobias Nyholm @@ -32,12 +33,12 @@ public function process(ContainerBuilder $container): void */ private function getExtractors(ContainerBuilder $container): array { - if (!$container->hasDefinition('php_translation.extractor')) { + if (!$container->hasDefinition(Extractor::class)) { return []; } /** @var Definition $def */ - $def = $container->getDefinition('php_translation.extractor'); + $def = $container->getDefinition(Extractor::class); $services = $container->findTaggedServiceIds('php_translation.extractor'); $extractors = []; foreach ($services as $id => $tags) { diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3b97088c..da7753b4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Translation\Bundle\EditInPlace\Activator; /** * This is the class that validates and merges configuration from your app/config files. @@ -199,7 +200,7 @@ private function addEditInPlaceNode(ArrayNodeDefinition $root): void ->canBeEnabled() ->children() ->scalarNode('config_name')->defaultValue('default')->end() - ->scalarNode('activator')->cannotBeEmpty()->defaultValue('php_translation.edit_in_place.activator')->end() + ->scalarNode('activator')->cannotBeEmpty()->defaultValue(Activator::class)->end() ->scalarNode('show_untranslatable')->defaultTrue()->end() ->end() ->end() diff --git a/DependencyInjection/TranslationExtension.php b/DependencyInjection/TranslationExtension.php index a5809cc8..9e10221f 100644 --- a/DependencyInjection/TranslationExtension.php +++ b/DependencyInjection/TranslationExtension.php @@ -20,8 +20,15 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\Kernel; +use Translation\Bundle\EventListener\AutoAddMissingTranslations; +use Translation\Bundle\EventListener\EditInPlaceResponseListener; use Translation\Bundle\Model\Configuration as ConfigurationModel; +use Translation\Bundle\Service\ConfigurationManager; +use Translation\Bundle\Service\StorageManager; use Translation\Bundle\Service\StorageService; +use Translation\Bundle\Translator\EditInPlaceTranslator; +use Translation\Bundle\Twig\EditInPlaceExtension; +use Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices; /** * This is the class that loads and manages your bundle configuration. @@ -43,7 +50,7 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('extractors.yaml'); // Add major version to extractor - $container->getDefinition('php_translation.extractor.php.visitor.FormTypeChoices') + $container->getDefinition(FormTypeChoices::class) ->addMethodCall('setSymfonyMajorVersion', [Kernel::MAJOR_VERSION]); $container->setParameter('php_translation.locales', $config['locales']); @@ -70,7 +77,7 @@ public function load(array $configs, ContainerBuilder $container): void if ($config['auto_add_missing_translations']['enabled']) { $loader->load('auto_add.yaml'); - $container->getDefinition('php_translator.auto_adder') + $container->getDefinition(AutoAddMissingTranslations::class) ->replaceArgument(0, new Reference('php_translation.storage.'.$config['auto_add_missing_translations']['config_name'])); } @@ -79,10 +86,6 @@ public function load(array $configs, ContainerBuilder $container): void $this->enableFallbackAutoTranslator($container, $config); } - if ('test' === \getenv('ENV')) { - $loader->load('services_test.yaml'); - } - $loader->load('console.yaml'); } @@ -91,8 +94,8 @@ public function load(array $configs, ContainerBuilder $container): void */ private function handleConfigNode(ContainerBuilder $container, array $config): void { - $storageManager = $container->getDefinition('php_translation.storage_manager'); - $configurationManager = $container->getDefinition('php_translation.configuration_manager'); + $storageManager = $container->getDefinition(StorageManager::class); + $configurationManager = $container->getDefinition(ConfigurationManager::class); // $first will be the "default" configuration. $first = null; foreach ($config['configs'] as $name => &$c) { @@ -179,15 +182,15 @@ private function enableEditInPlace(ContainerBuilder $container, array $config): $activatorRef = new Reference($config['edit_in_place']['activator']); - $def = $container->getDefinition('php_translation.edit_in_place.response_listener'); + $def = $container->getDefinition(EditInPlaceResponseListener::class); $def->replaceArgument(0, $activatorRef); $def->replaceArgument(3, $name); $def->replaceArgument(4, $config['edit_in_place']['show_untranslatable']); - $def = $container->getDefinition('php_translator.edit_in_place.xtrans_html_translator'); + $def = $container->getDefinition(EditInPlaceTranslator::class); $def->replaceArgument(1, $activatorRef); - $def = $container->getDefinition('php_translation.edit_in_place.extension.trans'); + $def = $container->getDefinition(EditInPlaceExtension::class); $def->replaceArgument(2, $activatorRef); } diff --git a/Resources/config/auto_add.yaml b/Resources/config/auto_add.yaml index 612586c4..56a5430c 100644 --- a/Resources/config/auto_add.yaml +++ b/Resources/config/auto_add.yaml @@ -1,6 +1,5 @@ services: - php_translator.auto_adder: - class: Translation\Bundle\EventListener\AutoAddMissingTranslations + Translation\Bundle\EventListener\AutoAddMissingTranslations: arguments: [ ~, '@?translator.data_collector' ] tags: - { name: kernel.event_listener, event: kernel.terminate, method: onTerminate, priority: 10 } diff --git a/Resources/config/auto_translation.yaml b/Resources/config/auto_translation.yaml index 40a8799d..70dd141f 100644 --- a/Resources/config/auto_translation.yaml +++ b/Resources/config/auto_translation.yaml @@ -1,6 +1,5 @@ services: - php_translator.fallback_translator: - class: Translation\Bundle\Translator\FallbackTranslator + Translation\Bundle\Translator\FallbackTranslator: public: false decorates: 'translator' decoration_priority: 10 diff --git a/Resources/config/console.yaml b/Resources/config/console.yaml index 956eb4d2..ab005652 100644 --- a/Resources/config/console.yaml +++ b/Resources/config/console.yaml @@ -1,51 +1,63 @@ services: - php_translator.console.delete_obsolete: - class: Translation\Bundle\Command\DeleteObsoleteCommand + Translation\Bundle\Command\DeleteObsoleteCommand: public: true arguments: - - '@php_translation.storage_manager' - - '@php_translation.configuration_manager' - - '@php_translation.catalogue_manager' - - '@php_translation.catalogue_fetcher' + - '@Translation\Bundle\Service\StorageManager' + - '@Translation\Bundle\Service\ConfigurationManager' + - '@Translation\Bundle\Catalogue\CatalogueManager' + - '@Translation\Bundle\Catalogue\CatalogueFetcher' tags: - { name: console.command, command: translation:delete-obsolete} - php_translator.console.download: - class: Translation\Bundle\Command\DownloadCommand + Translation\Bundle\Command\DownloadCommand: public: true arguments: - - '@php_translation.storage_manager' - - '@php_translation.configuration_manager' - - '@php_translation.cache_clearer' + - '@Translation\Bundle\Service\StorageManager' + - '@Translation\Bundle\Service\ConfigurationManager' + - '@Translation\Bundle\Service\CacheClearer' tags: - { name: console.command, command: translation:download } - php_translator.console.extract: - class: Translation\Bundle\Command\ExtractCommand + Translation\Bundle\Command\ExtractCommand: public: true arguments: - - '@php_translation.catalogue_fetcher' - - '@php_translation.catalogue_writer' - - '@php_translation.catalogue_counter' - - '@php_translation.importer' - - '@php_translation.configuration_manager' + - '@Translation\Bundle\Catalogue\CatalogueFetcher' + - '@Translation\Bundle\Catalogue\CatalogueWriter' + - '@Translation\Bundle\Catalogue\CatalogueCounter' + - '@Translation\Bundle\Service\Importer' + - '@Translation\Bundle\Service\ConfigurationManager' tags: - { name: console.command, command: translation:extract } - php_translator.console.status: - class: Translation\Bundle\Command\StatusCommand + Translation\Bundle\Command\StatusCommand: public: true arguments: - - '@php_translation.catalogue_counter' - - '@php_translation.configuration_manager' - - '@php_translation.catalogue_fetcher' + - '@Translation\Bundle\Catalogue\CatalogueCounter' + - '@Translation\Bundle\Service\ConfigurationManager' + - '@Translation\Bundle\Catalogue\CatalogueFetcher' tags: - { name: console.command, command: translation:status } - php_translator.console.sync: - class: Translation\Bundle\Command\SyncCommand + Translation\Bundle\Command\SyncCommand: public: true arguments: - - '@php_translation.storage_manager' + - '@Translation\Bundle\Service\StorageManager' tags: - { name: console.command, command: translation:sync } + + # To remove in next major release + php_translator.console.delete_obsolete: + parent: Translation\Bundle\Command\DeleteObsoleteCommand + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translator.console.download: + parent: Translation\Bundle\Command\DownloadCommand + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translator.console.extract: + parent: Translation\Bundle\Command\ExtractCommand + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translator.console.status: + parent: Translation\Bundle\Command\StatusCommand + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translator.console.sync: + parent: Translation\Bundle\Command\SyncCommand + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' diff --git a/Resources/config/edit_in_place.yaml b/Resources/config/edit_in_place.yaml index 55847815..f6180e55 100644 --- a/Resources/config/edit_in_place.yaml +++ b/Resources/config/edit_in_place.yaml @@ -8,8 +8,7 @@ services: - '@Translation\Bundle\Service\CacheClearer' - '@Symfony\Component\Validator\Validator\ValidatorInterface' - php_translation.edit_in_place.response_listener: - class: Translation\Bundle\EventListener\EditInPlaceResponseListener + Translation\Bundle\EventListener\EditInPlaceResponseListener: tags: - { name: 'kernel.event_listener', event: 'kernel.response', method: 'onKernelResponse' } arguments: @@ -19,24 +18,35 @@ services: - ~ - ~ - php_translation.edit_in_place.activator: - class: Translation\Bundle\EditInPlace\Activator + Translation\Bundle\EditInPlace\Activator: arguments: ['@session'] public: true - php_translator.edit_in_place.xtrans_html_translator: - class: Translation\Bundle\Translator\EditInPlaceTranslator + Translation\Bundle\Translator\EditInPlaceTranslator: arguments: - '@translator' - ~ - '@request_stack' - php_translation.edit_in_place.extension.trans: + Translation\Bundle\Twig\EditInPlaceExtension: public: false - class: Translation\Bundle\Twig\EditInPlaceExtension arguments: - '@twig.extension.trans' - '@request_stack' - ~ tags: - { name: 'twig.extension' } + + # To remove in next major release + php_translation.edit_in_place.response_listener: + parent: Translation\Bundle\EventListener\EditInPlaceResponseListener + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.edit_in_place.activator: + parent: Translation\Bundle\EditInPlace\Activator + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translator.edit_in_place.xtrans_html_translator: + parent: Translation\Bundle\Translator\EditInPlaceTranslator + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.edit_in_place.extension.trans: + parent: Translation\Bundle\Twig\EditInPlaceExtension + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' diff --git a/Resources/config/extractors.yaml b/Resources/config/extractors.yaml index 61fb91c5..0f254dc3 100644 --- a/Resources/config/extractors.yaml +++ b/Resources/config/extractors.yaml @@ -1,79 +1,111 @@ services: - php_translation.extractor.php: - class: Translation\Extractor\FileExtractor\PHPFileExtractor + Translation\Extractor\FileExtractor\PHPFileExtractor: tags: - { name: 'php_translation.extractor', type: 'php' } - php_translation.extractor.twig: - class: Translation\Extractor\FileExtractor\TwigFileExtractor + Translation\Extractor\FileExtractor\TwigFileExtractor: arguments: ["@twig"] tags: - { name: 'php_translation.extractor', type: 'twig' } # PHP Visitors: - php_translation.extractor.php.visitor.ContainerAwareTrans: - class: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans + Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.ContainerAwareTransChoice: - class: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice + Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FlashMessage: - class: Translation\Extractor\Visitor\Php\Symfony\FlashMessage + Translation\Extractor\Visitor\Php\Symfony\FlashMessage: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypeChoices: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices + Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypeEmptyValue: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue + Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypeHelp: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp + Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypeInvalidMessage: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage + Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypeLabelExplicit: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit + Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypeLabelImplicit: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit + Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.FormTypePlaceholder: - class: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder + Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder: tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.ValidationAnnotation: - class: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation + Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation: arguments: ['@validator'] tags: - { name: 'php_translation.visitor', type: 'php' } - php_translation.extractor.php.visitor.SourceLocationContainerVisitor: - class: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor + Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor: tags: - { name: 'php_translation.visitor', type: 'php' } # Twig Visitors: - php_translation.extractor.twig.factory.twig: - class: Translation\Extractor\Visitor\Twig\TwigVisitor + Translation\Extractor\Visitor\Twig\TwigVisitor: tags: - { name: 'php_translation.visitor', type: 'twig' } + + # To remove in next major release + php_translation.extractor.php: + parent: Translation\Extractor\FileExtractor\PHPFileExtractor + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.twig: + parent: Translation\Extractor\FileExtractor\TwigFileExtractor + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.ContainerAwareTrans: + parent: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.ContainerAwareTransChoice: + parent: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FlashMessage: + parent: Translation\Extractor\Visitor\Php\Symfony\FlashMessage + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeChoices: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeEmptyValue: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeHelp: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeInvalidMessage: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeLabelExplicit: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeLabelImplicit: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypePlaceholder: + parent: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.ValidationAnnotation: + parent: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.php.visitor.SourceLocationContainerVisitor: + parent: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.extractor.twig.factory.twig: + parent: Translation\Extractor\Visitor\Twig\TwigVisitor + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' diff --git a/Resources/config/services.yaml b/Resources/config/services.yaml index 104420a8..b065dbac 100644 --- a/Resources/config/services.yaml +++ b/Resources/config/services.yaml @@ -1,68 +1,85 @@ services: - php_translation.catalogue_fetcher: - public: true - class: Translation\Bundle\Catalogue\CatalogueFetcher - arguments: ["@translation.reader"] Translation\Bundle\Catalogue\CatalogueFetcher: - alias: php_translation.catalogue_fetcher + public: true + arguments: ['@translation.reader'] - php_translation.catalogue_writer: + Translation\Bundle\Catalogue\CatalogueWriter: public: true - class: Translation\Bundle\Catalogue\CatalogueWriter - arguments: ["@translation.writer", "%php_translation.default_locale%"] + arguments: ['@translation.writer', '%php_translation.default_locale%'] php_translation.storage.abstract: class: Translation\Bundle\Service\StorageService abstract: true - arguments: ["@php_translation.catalogue_fetcher", "@php_translation.catalogue_writer", ~] + arguments: ['@Translation\Bundle\Catalogue\CatalogueFetcher', '@Translation\Bundle\Catalogue\CatalogueWriter', ~] - php_translation.catalogue_manager: - public: true - class: Translation\Bundle\Catalogue\CatalogueManager Translation\Bundle\Catalogue\CatalogueManager: - alias: php_translation.catalogue_manager + public: true - php_translation.extractor: - class: Translation\Extractor\Extractor + Translation\Extractor\Extractor: ~ - php_translation.storage_manager: - public: true - class: Translation\Bundle\Service\StorageManager Translation\Bundle\Service\StorageManager: - alias: php_translation.storage_manager public: true - php_translation.configuration_manager: - public: true - class: Translation\Bundle\Service\ConfigurationManager Translation\Bundle\Service\ConfigurationManager: - alias: php_translation.configuration_manager - - php_translation.importer: public: true - class: Translation\Bundle\Service\Importer - arguments: ["@php_translation.extractor", "@twig", "%php_translation.default_locale%"] - php_translation.cache_clearer: + Translation\Bundle\Service\Importer: public: true - class: Translation\Bundle\Service\CacheClearer - arguments: ["%kernel.cache_dir%", "@translator", "@filesystem"] + arguments: ['@Translation\Extractor\Extractor', '@twig', '%php_translation.default_locale%'] + Translation\Bundle\Service\CacheClearer: - alias: php_translation.cache_clearer public: true + arguments: ['%kernel.cache_dir%', '@translator', '@filesystem'] php_translation.local_file_storage.abstract: class: Translation\SymfonyStorage\FileStorage abstract: true - arguments: ["@translation.writer", "@translation.reader", ~, []] + arguments: ['@translation.writer', '@translation.reader', ~, []] - php_translation.catalogue_counter: + Translation\Bundle\Catalogue\CatalogueCounter: public: true - class: Translation\Bundle\Catalogue\CatalogueCounter - arguments: [] - php_translation.twig_extension: - class: Translation\Bundle\Twig\TranslationExtension - arguments: ['@translator', "%kernel.debug%"] + Translation\Bundle\Twig\TranslationExtension: + arguments: ['@translator', '%kernel.debug%'] tags: - { name: twig.extension } + + # To remove in next major release + php_translation.catalogue_fetcher: + parent: Translation\Bundle\Catalogue\CatalogueFetcher + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + public: true + php_translation.catalogue_writer: + parent: Translation\Bundle\Catalogue\CatalogueWriter + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + public: true + php_translation.catalogue_manager: + parent: Translation\Bundle\Catalogue\CatalogueManager + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + public: true + php_translation.extractor: + parent: Translation\Extractor\Extractor + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.storage_manager: + parent: Translation\Bundle\Service\StorageManager + public: true + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.configuration_manager: + parent: Translation\Bundle\Service\ConfigurationManager + public: true + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.importer: + parent: Translation\Bundle\Service\Importer + public: true + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.cache_clearer: + parent: Translation\Bundle\Service\CacheClearer + public: true + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.catalogue_counter: + parent: Translation\Bundle\Catalogue\CatalogueCounter + public: true + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + php_translation.twig_extension: + parent: Translation\Bundle\Twig\TranslationExtension + deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' diff --git a/Resources/config/services_test.yaml b/Resources/config/services_test.yaml deleted file mode 100644 index 6dc80eae..00000000 --- a/Resources/config/services_test.yaml +++ /dev/null @@ -1,16 +0,0 @@ -services: - test.php_translation.edit_in_place.activator: - public: true - alias: 'php_translation.edit_in_place.activator' - - test.php_translation.extractor.php: - public: true - alias: 'php_translation.extractor.php' - - test.php_translation.extractor.twig: - public: true - alias: 'php_translation.extractor.twig' - - test.php_translation.extractor: - public: true - alias: 'php_translation.extractor' diff --git a/Tests/Functional/BundleInitializationTest.php b/Tests/Functional/BundleInitializationTest.php index b28b533e..01570a90 100644 --- a/Tests/Functional/BundleInitializationTest.php +++ b/Tests/Functional/BundleInitializationTest.php @@ -16,9 +16,6 @@ use Translation\Bundle\Catalogue\CatalogueWriter; use Translation\Bundle\Service\ConfigurationManager; use Translation\Bundle\Service\StorageService; -use Translation\Extractor\Extractor; -use Translation\Extractor\FileExtractor\PHPFileExtractor; -use Translation\Extractor\FileExtractor\TwigFileExtractor; class BundleInitializationTest extends BaseTestCase { @@ -26,8 +23,8 @@ public function testRegisterBundle(): void { $this->bootKernel(); $container = $this->getContainer(); - $this->assertTrue($container->has('php_translation.configuration_manager')); - $config = $container->get('php_translation.configuration_manager'); + $this->assertTrue($container->has(ConfigurationManager::class)); + $config = $container->get(ConfigurationManager::class); $this->assertInstanceOf(ConfigurationManager::class, $config); $default = $config->getConfiguration(); @@ -35,16 +32,15 @@ public function testRegisterBundle(): void $this->assertEquals($root.'/Resources/translations', $default->getOutputDir()); $services = [ + CatalogueFetcher::class, + CatalogueManager::class, + CatalogueWriter::class, 'php_translation.storage' => StorageService::class, - 'test.php_translation.extractor.twig' => TwigFileExtractor::class, - 'test.php_translation.extractor.php' => PHPFileExtractor::class, - 'php_translation.catalogue_fetcher' => CatalogueFetcher::class, - 'php_translation.catalogue_writer' => CatalogueWriter::class, - 'php_translation.catalogue_manager' => CatalogueManager::class, - 'test.php_translation.extractor' => Extractor::class, ]; foreach ($services as $id => $class) { + $id = \is_int($id) ? $class : $id; + $this->assertTrue($container->has($id)); $s = $container->get($id); $this->assertInstanceOf($class, $s); diff --git a/Tests/Functional/Catalogue/CatalogueFetcherTest.php b/Tests/Functional/Catalogue/CatalogueFetcherTest.php index 169c168b..eb6034c7 100644 --- a/Tests/Functional/Catalogue/CatalogueFetcherTest.php +++ b/Tests/Functional/Catalogue/CatalogueFetcherTest.php @@ -54,7 +54,7 @@ public function testFetchCatalogue(): void { $this->bootKernel(); - $this->catalogueFetcher = $this->getContainer()->get('php_translation.catalogue_fetcher'); + $this->catalogueFetcher = $this->getContainer()->get(CatalogueFetcher::class); $data = self::getDefaultData(); $data['external_translations_dirs'] = [__DIR__.'/../app/Resources/translations/']; diff --git a/Tests/Functional/Command/ExtractCommandTest.php b/Tests/Functional/Command/ExtractCommandTest.php index 62137361..786c44f7 100644 --- a/Tests/Functional/Command/ExtractCommandTest.php +++ b/Tests/Functional/Command/ExtractCommandTest.php @@ -14,7 +14,10 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\HttpKernel\Kernel; +use Translation\Bundle\Catalogue\CatalogueFetcher; +use Translation\Bundle\Command\ExtractCommand; use Translation\Bundle\Model\Metadata; +use Translation\Bundle\Service\ConfigurationManager; use Translation\Bundle\Tests\Functional\BaseTestCase; class ExtractCommandTest extends BaseTestCase @@ -68,7 +71,7 @@ public function testExecute(): void $application = new Application($this->kernel); $container = $this->getContainer(); - $application->add($container->get('php_translator.console.extract')); + $application->add($container->get(ExtractCommand::class)); // transchoice tag have been definively removed in sf ^5.0 // Remove this condition & views_with_transchoice + associated config once sf ^5.0 is the minimum supported version. @@ -94,8 +97,8 @@ public function testExecute(): void $this->assertRegExp('|Total defined messages +8|s', $output); $container = $this->getContainer(); - $config = $container->get('php_translation.configuration_manager')->getConfiguration('app'); - $catalogues = $container->get('php_translation.catalogue_fetcher')->getCatalogues($config, ['sv']); + $config = $container->get(ConfigurationManager::class)->getConfiguration('app'); + $catalogues = $container->get(CatalogueFetcher::class)->getCatalogues($config, ['sv']); $catalogue = $catalogues[0]; $this->assertEquals('My translated heading', $catalogue->get('translated.heading'), 'Translated strings MUST NOT disappear.'); diff --git a/Tests/Functional/Command/StatusCommandTest.php b/Tests/Functional/Command/StatusCommandTest.php index 84ec718b..2633fb8c 100644 --- a/Tests/Functional/Command/StatusCommandTest.php +++ b/Tests/Functional/Command/StatusCommandTest.php @@ -13,6 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; +use Translation\Bundle\Command\StatusCommand; use Translation\Bundle\Tests\Functional\BaseTestCase; class StatusCommandTest extends BaseTestCase @@ -29,7 +30,7 @@ public function testExecute(): void $application = new Application($this->kernel); $container = $this->getContainer(); - $application->add($container->get('php_translator.console.status')); + $application->add($container->get(StatusCommand::class)); $command = $application->find('translation:status'); $commandTester = new CommandTester($command); diff --git a/Tests/Functional/Command/SyncCommandTest.php b/Tests/Functional/Command/SyncCommandTest.php index 8ace7cc6..b06255fa 100644 --- a/Tests/Functional/Command/SyncCommandTest.php +++ b/Tests/Functional/Command/SyncCommandTest.php @@ -13,6 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; +use Translation\Bundle\Command\SyncCommand; use Translation\Bundle\Tests\Functional\BaseTestCase; class SyncCommandTest extends BaseTestCase @@ -66,7 +67,7 @@ public function testExecute(): void $application = new Application($this->kernel); $container = $this->getContainer(); - $application->add($container->get('php_translator.console.sync')); + $application->add($container->get(SyncCommand::class)); $command = $application->find('translation:sync'); $commandTester = new CommandTester($command); diff --git a/Tests/Functional/Controller/EditInPlaceTest.php b/Tests/Functional/Controller/EditInPlaceTest.php index 256c2459..924c8bfd 100644 --- a/Tests/Functional/Controller/EditInPlaceTest.php +++ b/Tests/Functional/Controller/EditInPlaceTest.php @@ -12,6 +12,7 @@ namespace Translation\Bundle\Tests\Functional\Controller; use Symfony\Component\HttpFoundation\Request; +use Translation\Bundle\EditInPlace\Activator; use Translation\Bundle\Tests\Functional\BaseTestCase; /** @@ -25,7 +26,7 @@ public function testActivatedTest(): void $request = Request::create('/foobar'); // Activate the feature - $this->getContainer()->get('test.php_translation.edit_in_place.activator')->activate(); + $this->getContainer()->get(Activator::class)->activate(); $response = $this->kernel->handle($request); @@ -57,7 +58,7 @@ public function testIfUntranslatableLabelGetsDisabled(): void // Activate the feature $this->bootKernel(); - $this->getContainer()->get('test.php_translation.edit_in_place.activator')->activate(); + $this->getContainer()->get(Activator::class)->activate(); $response = $this->kernel->handle($request); diff --git a/Tests/Unit/DependencyInjection/CompilerPass/EditInPlacePassTest.php b/Tests/Unit/DependencyInjection/CompilerPass/EditInPlacePassTest.php index 9fe98d42..da7ccc74 100644 --- a/Tests/Unit/DependencyInjection/CompilerPass/EditInPlacePassTest.php +++ b/Tests/Unit/DependencyInjection/CompilerPass/EditInPlacePassTest.php @@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Translation\Bundle\DependencyInjection\CompilerPass\EditInPlacePass; +use Translation\Bundle\Translator\EditInPlaceTranslator; class EditInPlacePassTest extends AbstractCompilerPassTestCase { @@ -27,7 +28,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void public function testReplacement(): void { $def = new Definition(); - $this->setDefinition('php_translator.edit_in_place.xtrans_html_translator', $def); + $this->setDefinition(EditInPlaceTranslator::class, $def); $twigExtension = new Definition(); $twigExtension->addArgument('should_be_replaced'); @@ -35,6 +36,6 @@ public function testReplacement(): void $this->compile(); - $this->assertContainerBuilderHasServiceDefinitionWithArgument('twig.extension.trans', 0, new Reference('php_translator.edit_in_place.xtrans_html_translator')); + $this->assertContainerBuilderHasServiceDefinitionWithArgument('twig.extension.trans', 0, new Reference(EditInPlaceTranslator::class)); } } diff --git a/Tests/Unit/DependencyInjection/CompilerPass/ExtractorPassTest.php b/Tests/Unit/DependencyInjection/CompilerPass/ExtractorPassTest.php index cd005391..6415147f 100644 --- a/Tests/Unit/DependencyInjection/CompilerPass/ExtractorPassTest.php +++ b/Tests/Unit/DependencyInjection/CompilerPass/ExtractorPassTest.php @@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Translation\Bundle\DependencyInjection\CompilerPass\ExtractorPass; +use Translation\Extractor\Extractor; class ExtractorPassTest extends AbstractCompilerPassTestCase { @@ -30,7 +31,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void public function if_compiler_pass_collects_services_by_adding_method_calls_these_will_exist(): void { $collectingService = new Definition(); - $this->setDefinition('php_translation.extractor', $collectingService); + $this->setDefinition(Extractor::class, $collectingService); $collectedService = new Definition(); $collectedService->addTag('php_translation.extractor', ['type' => 'html']); @@ -39,7 +40,7 @@ public function if_compiler_pass_collects_services_by_adding_method_calls_these_ $this->compile(); $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( - 'php_translation.extractor', + Extractor::class, 'addFileExtractor', [new Reference('collected_service')] ); diff --git a/Tests/Unit/DependencyInjection/TranslationExtensionTest.php b/Tests/Unit/DependencyInjection/TranslationExtensionTest.php index e1dc1ebb..b0999b15 100644 --- a/Tests/Unit/DependencyInjection/TranslationExtensionTest.php +++ b/Tests/Unit/DependencyInjection/TranslationExtensionTest.php @@ -72,20 +72,20 @@ public function testEditInPlaceEnabled(): void { $this->load(['edit_in_place' => ['enabled' => true]]); - $this->assertContainerBuilderHasService('php_translation.edit_in_place.response_listener', EditInPlaceResponseListener::class); + $this->assertContainerBuilderHasService(EditInPlaceResponseListener::class); } public function testAutoAddEnabled(): void { $this->load(['auto_add_missing_translations' => ['enabled' => true]]); - $this->assertContainerBuilderHasService('php_translator.auto_adder', AutoAddMissingTranslations::class); + $this->assertContainerBuilderHasService(AutoAddMissingTranslations::class); } public function testFallbackTranslationEnabled(): void { $this->load(['fallback_translation' => ['enabled' => true]]); - $this->assertContainerBuilderHasService('php_translator.fallback_translator', FallbackTranslator::class); + $this->assertContainerBuilderHasService(FallbackTranslator::class); } }