From 4d2013bfe6dd35f44ff34cf4a3df8a3d9d5d8b28 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Fri, 8 Jun 2018 23:19:27 +0200 Subject: [PATCH 1/2] Fix the FileDumper::setBackup() method deprecation notice Also adds a compiler pass to assure the service definition remains unchanged on older Symfony versions --- .../CompilerPass/FileDumperBackupPass.php | 23 +++++++++++++++++++ Resources/config/services.yml | 2 -- TranslationBundle.php | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 DependencyInjection/CompilerPass/FileDumperBackupPass.php diff --git a/DependencyInjection/CompilerPass/FileDumperBackupPass.php b/DependencyInjection/CompilerPass/FileDumperBackupPass.php new file mode 100644 index 00000000..6027b89a --- /dev/null +++ b/DependencyInjection/CompilerPass/FileDumperBackupPass.php @@ -0,0 +1,23 @@ +getDefinition('php_translation.storage.xlf_dumper'); + $definition->addMethodCall('setBackup', [false]); + } + } +} diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 355ca6ec..5ef264e9 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -53,8 +53,6 @@ services: class: Translation\SymfonyStorage\Dumper\XliffDumper tags: - { name: translation.dumper, alias: xlf, legacy-alias: xliff } - calls: - - [setBackup, [false]] php_translation.catalogue_counter: public: true diff --git a/TranslationBundle.php b/TranslationBundle.php index f8976c04..2c4cfff8 100644 --- a/TranslationBundle.php +++ b/TranslationBundle.php @@ -16,6 +16,7 @@ use Translation\Bundle\DependencyInjection\CompilerPass\EditInPlacePass; use Translation\Bundle\DependencyInjection\CompilerPass\ExternalTranslatorPass; use Translation\Bundle\DependencyInjection\CompilerPass\ExtractorPass; +use Translation\Bundle\DependencyInjection\CompilerPass\FileDumperBackupPass; use Translation\Bundle\DependencyInjection\CompilerPass\LoaderOrReaderPass; use Translation\Bundle\DependencyInjection\CompilerPass\StoragePass; use Translation\Bundle\DependencyInjection\CompilerPass\SymfonyProfilerPass; @@ -35,5 +36,6 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new StoragePass()); $container->addCompilerPass(new EditInPlacePass()); $container->addCompilerPass(new LoaderOrReaderPass()); + $container->addCompilerPass(new FileDumperBackupPass()); } } From 398f58a553e0f626d91df9b1a25e6ab99ed61bfc Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 9 Jun 2018 21:59:46 +0200 Subject: [PATCH 2/2] Convert logic in compiler pass to fail-fast and fix styleci issues --- .../CompilerPass/FileDumperBackupPass.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/CompilerPass/FileDumperBackupPass.php b/DependencyInjection/CompilerPass/FileDumperBackupPass.php index 6027b89a..0b7b48ed 100644 --- a/DependencyInjection/CompilerPass/FileDumperBackupPass.php +++ b/DependencyInjection/CompilerPass/FileDumperBackupPass.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Translation\Bundle\DependencyInjection\CompilerPass; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -15,9 +24,11 @@ class FileDumperBackupPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - if (Kernel::MAJOR_VERSION <= 3) { - $definition = $container->getDefinition('php_translation.storage.xlf_dumper'); - $definition->addMethodCall('setBackup', [false]); + if (Kernel::MAJOR_VERSION >= 4) { + return; } + + $definition = $container->getDefinition('php_translation.storage.xlf_dumper'); + $definition->addMethodCall('setBackup', [false]); } }