diff --git a/DependencyInjection/TranslationExtension.php b/DependencyInjection/TranslationExtension.php index 11ed972e..7fdb0582 100644 --- a/DependencyInjection/TranslationExtension.php +++ b/DependencyInjection/TranslationExtension.php @@ -47,9 +47,12 @@ public function load(array $configs, ContainerBuilder $container): void $configuration = new Configuration($container); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $legacyLoader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/legacy')); $loader->load('services.yaml'); + $legacyLoader->load('services.php'); $loader->load('extractors.yaml'); + $legacyLoader->load('extractors.php'); // Add major version to extractor $container->getDefinition(FormTypeChoices::class) @@ -74,6 +77,7 @@ public function load(array $configs, ContainerBuilder $container): void if ($config['edit_in_place']['enabled']) { $loader->load('edit_in_place.yaml'); + $legacyLoader->load('edit_in_place.php'); $this->enableEditInPlace($container, $config); } @@ -89,6 +93,7 @@ public function load(array $configs, ContainerBuilder $container): void } $loader->load('console.yaml'); + $legacyLoader->load('console.php'); } /** diff --git a/Legacy/LegacyHelper.php b/Legacy/LegacyHelper.php index 1b334915..c59cba6d 100644 --- a/Legacy/LegacyHelper.php +++ b/Legacy/LegacyHelper.php @@ -11,7 +11,9 @@ namespace Translation\Bundle\Legacy; +use Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpKernel\Kernel; /** * A legacy helper to suppress deprecations on RequestStack. @@ -28,4 +30,30 @@ public static function getMainRequest(RequestStack $requestStack) return $requestStack->getMasterRequest(); } + + /** + * @param array[string $id, string $parent, ?bool $isPublic] $legacyServices + */ + public static function registerDeprecatedServices(ServicesConfigurator $servicesConfigurator, array $legacyServices) + { + foreach ($legacyServices as $legacyService) { + $id = $legacyService[0]; + $parent = $legacyService[1]; + $isPublic = $legacyService[2] ?? false; + + // Declare legacy services to remove in next major release + $service = $servicesConfigurator->set($id) + ->parent($parent); + + if (Kernel::VERSION_ID < 50100) { + $service->deprecate('Since php-translation/symfony-bundle 0.10.0: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.'); + } else { + $service->deprecate('php-translation/symfony-bundle', '0.10.0', 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.'); + } + + if ($isPublic) { + $service->public(); + } + } + } } diff --git a/Resources/config/console.yaml b/Resources/config/console.yaml index dcbf06ec..2a003472 100644 --- a/Resources/config/console.yaml +++ b/Resources/config/console.yaml @@ -65,20 +65,3 @@ services: - '@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 f6180e55..47f4220e 100644 --- a/Resources/config/edit_in_place.yaml +++ b/Resources/config/edit_in_place.yaml @@ -36,17 +36,3 @@ services: - ~ 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 a692eeca..68bb9095 100644 --- a/Resources/config/extractors.yaml +++ b/Resources/config/extractors.yaml @@ -24,52 +24,5 @@ services: tags: - { name: 'php_translation.visitor', type: 'twig' } - # To remove in next major release - php_translation.extractor.php: - alias: Translation\Extractor\FileExtractor\PHPFileExtractor - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.twig: - alias: Translation\Extractor\FileExtractor\TwigFileExtractor - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.ContainerAwareTrans: - alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.ContainerAwareTransChoice: - alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FlashMessage: - alias: Translation\Extractor\Visitor\Php\Symfony\FlashMessage - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeChoices: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeEmptyValue: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeHelp: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeInvalidMessage: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeLabelExplicit: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeLabelImplicit: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypePlaceholder: - alias: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.ValidationAnnotation: - alias: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.php.visitor.SourceLocationContainerVisitor: - alias: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - php_translation.extractor.twig.factory.twig: - alias: Translation\Extractor\Visitor\Twig\TwigVisitor - deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' - Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation: arguments: ['@validator'] diff --git a/Resources/config/legacy/console.php b/Resources/config/legacy/console.php new file mode 100644 index 00000000..568b10e8 --- /dev/null +++ b/Resources/config/legacy/console.php @@ -0,0 +1,20 @@ +services(), [ + ['php_translator.console.delete_obsolete', DeleteObsoleteCommand::class], + ['php_translator.console.download', DownloadCommand::class], + ['php_translator.console.extract', ExtractCommand::class], + ['php_translator.console.status', StatusCommand::class], + ['php_translator.console.sync', SyncCommand::class], + ]); +}; diff --git a/Resources/config/legacy/edit_in_place.php b/Resources/config/legacy/edit_in_place.php new file mode 100644 index 00000000..92127954 --- /dev/null +++ b/Resources/config/legacy/edit_in_place.php @@ -0,0 +1,18 @@ +services(), [ + ['php_translation.edit_in_place.response_listener', EditInPlaceResponseListener::class], + ['php_translation.edit_in_place.activator', Activator::class], + ['php_translator.edit_in_place.xtrans_html_translator', EditInPlaceTranslator::class], + ['php_translation.edit_in_place.extension.trans', EditInPlaceExtension::class], + ]); +}; diff --git a/Resources/config/legacy/extractors.php b/Resources/config/legacy/extractors.php new file mode 100644 index 00000000..687b4b9d --- /dev/null +++ b/Resources/config/legacy/extractors.php @@ -0,0 +1,40 @@ +services(), [ + ['php_translation.extractor.php', PHPFileExtractor::class], + ['php_translation.extractor.twig', TwigFileExtractor::class], + ['php_translation.extractor.php.visitor.ContainerAwareTrans', ContainerAwareTrans::class], + ['php_translation.extractor.php.visitor.ContainerAwareTransChoice', ContainerAwareTransChoice::class], + ['php_translation.extractor.php.visitor.FlashMessage', FlashMessage::class], + ['php_translation.extractor.php.visitor.FormTypeChoices', FormTypeChoices::class], + ['php_translation.extractor.php.visitor.FormTypeEmptyValue', FormTypeEmptyValue::class], + ['php_translation.extractor.php.visitor.FormTypeHelp', FormTypeHelp::class], + ['php_translation.extractor.php.visitor.FormTypeInvalidMessage', FormTypeInvalidMessage::class], + ['php_translation.extractor.php.visitor.FormTypeLabelExplicit', FormTypeLabelExplicit::class], + ['php_translation.extractor.php.visitor.FormTypeLabelImplicit', FormTypeLabelImplicit::class], + ['php_translation.extractor.php.visitor.FormTypePlaceholder', FormTypePlaceholder::class], + ['php_translation.extractor.php.visitor.ValidationAnnotation', ValidationAnnotation::class], + ['php_translation.extractor.php.visitor.SourceLocationContainerVisitor', SourceLocationContainerVisitor::class], + ['php_translation.extractor.twig.factory.twig', TwigVisitor::class], + ]); +}; diff --git a/Resources/config/legacy/services.php b/Resources/config/legacy/services.php new file mode 100644 index 00000000..9daaf626 --- /dev/null +++ b/Resources/config/legacy/services.php @@ -0,0 +1,30 @@ +services(), [ + ['php_translation.catalogue_fetcher', CatalogueFetcher::class, true], + ['php_translation.catalogue_writer', CatalogueWriter::class, true], + ['php_translation.catalogue_manager', CatalogueManager::class, true], + ['php_translation.extractor', Extractor::class], + ['php_translation.storage_manager', StorageManager::class, true], + ['php_translation.configuration_manager', ConfigurationManager::class, true], + ['php_translation.importer', Importer::class, true], + ['php_translation.cache_clearer', CacheClearer::class, true], + ['php_translation.catalogue_counter', CatalogueCounter::class, true], + ['php_translation.twig_extension', TranslationExtension::class], + ]); +}; diff --git a/Resources/config/services.yaml b/Resources/config/services.yaml index 23cec40c..646e1acb 100644 --- a/Resources/config/services.yaml +++ b/Resources/config/services.yaml @@ -43,43 +43,3 @@ services: 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.'