Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions DependencyInjection/CompilerPass/FileDumperBackupPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the PHP Translation package.
*
* (c) PHP Translation team <tobias.nyholm@gmail.com>
*
* 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;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;

/**
* The FileDumper::setBackup is deprecated since Symfony 4.1.
* This compiler pass assures our service definition remains unchanged for older symfony versions (3 or lower)
* while keeping the latest version clean of deprecation notices.
*/
class FileDumperBackupPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (Kernel::MAJOR_VERSION >= 4) {
return;
}

$definition = $container->getDefinition('php_translation.storage.xlf_dumper');
$definition->addMethodCall('setBackup', [false]);
}
}
2 changes: 0 additions & 2 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions TranslationBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}