[Translation] remove deprecated features

This commit is contained in:
Christian Flothmann 2017-05-21 11:15:41 +02:00
parent da61abdf20
commit 3a03de0787
4 changed files with 13 additions and 39 deletions

View File

@ -1,6 +1,11 @@
CHANGELOG CHANGELOG
========= =========
4.0.0
-----
* removed the backup feature of the `FileDumper` class
3.2.0 3.2.0
----- -----

View File

@ -17,7 +17,6 @@ use Symfony\Component\Translation\Exception\RuntimeException;
/** /**
* FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s). * FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s).
* Performs backup of already existing files.
* *
* Options: * Options:
* - path (mandatory): the directory where the files should be saved * - path (mandatory): the directory where the files should be saved
@ -33,13 +32,6 @@ abstract class FileDumper implements DumperInterface
*/ */
protected $relativePathTemplate = '%domain%.%locale%.%extension%'; protected $relativePathTemplate = '%domain%.%locale%.%extension%';
/**
* Make file backup before the dump.
*
* @var bool
*/
private $backup = true;
/** /**
* Sets the template for the relative paths to files. * Sets the template for the relative paths to files.
* *
@ -57,7 +49,12 @@ abstract class FileDumper implements DumperInterface
*/ */
public function setBackup($backup) public function setBackup($backup)
{ {
$this->backup = $backup; if (false !== $backup) {
throw new \LogicException('The backup feature is no longer supported.');
}
// the method is only present to not break BC
// to be deprecated in 4.1
} }
/** /**
@ -71,14 +68,8 @@ abstract class FileDumper implements DumperInterface
// save a file for each domain // save a file for each domain
foreach ($messages->getDomains() as $domain) { foreach ($messages->getDomains() as $domain) {
// backup
$fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale()); $fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
if (file_exists($fullpath)) { if (!file_exists($fullpath)) {
if ($this->backup) {
@trigger_error('Creating a backup while dumping a message catalogue is deprecated since version 3.1 and will be removed in 4.0. Use TranslationWriter::disableBackup() to disable the backup.', E_USER_DEPRECATED);
copy($fullpath, $fullpath.'~');
}
} else {
$directory = dirname($fullpath); $directory = dirname($fullpath);
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) { if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory)); throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory));

View File

@ -30,29 +30,6 @@ class FileDumperTest extends TestCase
$this->assertFileExists($tempDir.'/messages.en.concrete'); $this->assertFileExists($tempDir.'/messages.en.concrete');
} }
/**
* @group legacy
*/
public function testDumpBackupsFileIfExisting()
{
$tempDir = sys_get_temp_dir();
$file = $tempDir.'/messages.en.concrete';
$backupFile = $file.'~';
@touch($file);
$catalogue = new MessageCatalogue('en');
$catalogue->add(array('foo' => 'bar'));
$dumper = new ConcreteFileDumper();
$dumper->dump($catalogue, array('path' => $tempDir));
$this->assertFileExists($backupFile);
@unlink($file);
@unlink($backupFile);
}
public function testDumpCreatesNestedDirectoriesAndFile() public function testDumpCreatesNestedDirectoriesAndFile()
{ {
$tempDir = sys_get_temp_dir(); $tempDir = sys_get_temp_dir();

View File

@ -46,6 +46,7 @@ class TranslationWriter
*/ */
public function disableBackup() public function disableBackup()
{ {
// to be deprecated in 4.1
foreach ($this->dumpers as $dumper) { foreach ($this->dumpers as $dumper) {
if (method_exists($dumper, 'setBackup')) { if (method_exists($dumper, 'setBackup')) {
$dumper->setBackup(false); $dumper->setBackup(false);