Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d741908

Browse files
committed
feature #22879 [Translation] remove deprecated features (xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- [Translation] remove deprecated features | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 3a03de0 [Translation] remove deprecated features
2 parents ad2c9f0 + 3a03de0 commit d741908

File tree

4 files changed

+13
-39
lines changed

4 files changed

+13
-39
lines changed

src/Symfony/Component/Translation/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
-----
6+
7+
* removed the backup feature of the `FileDumper` class
8+
49
3.2.0
510
-----
611

src/Symfony/Component/Translation/Dumper/FileDumper.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
/**
1919
* FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s).
20-
* Performs backup of already existing files.
2120
*
2221
* Options:
2322
* - path (mandatory): the directory where the files should be saved
@@ -33,13 +32,6 @@ abstract class FileDumper implements DumperInterface
3332
*/
3433
protected $relativePathTemplate = '%domain%.%locale%.%extension%';
3534

36-
/**
37-
* Make file backup before the dump.
38-
*
39-
* @var bool
40-
*/
41-
private $backup = true;
42-
4335
/**
4436
* Sets the template for the relative paths to files.
4537
*
@@ -57,7 +49,12 @@ public function setRelativePathTemplate($relativePathTemplate)
5749
*/
5850
public function setBackup($backup)
5951
{
60-
$this->backup = $backup;
52+
if (false !== $backup) {
53+
throw new \LogicException('The backup feature is no longer supported.');
54+
}
55+
56+
// the method is only present to not break BC
57+
// to be deprecated in 4.1
6158
}
6259

6360
/**
@@ -71,14 +68,8 @@ public function dump(MessageCatalogue $messages, $options = array())
7168

7269
// save a file for each domain
7370
foreach ($messages->getDomains() as $domain) {
74-
// backup
7571
$fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
76-
if (file_exists($fullpath)) {
77-
if ($this->backup) {
78-
@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);
79-
copy($fullpath, $fullpath.'~');
80-
}
81-
} else {
72+
if (!file_exists($fullpath)) {
8273
$directory = dirname($fullpath);
8374
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
8475
throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory));

src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,6 @@ public function testDump()
3030
$this->assertFileExists($tempDir.'/messages.en.concrete');
3131
}
3232

33-
/**
34-
* @group legacy
35-
*/
36-
public function testDumpBackupsFileIfExisting()
37-
{
38-
$tempDir = sys_get_temp_dir();
39-
$file = $tempDir.'/messages.en.concrete';
40-
$backupFile = $file.'~';
41-
42-
@touch($file);
43-
44-
$catalogue = new MessageCatalogue('en');
45-
$catalogue->add(array('foo' => 'bar'));
46-
47-
$dumper = new ConcreteFileDumper();
48-
$dumper->dump($catalogue, array('path' => $tempDir));
49-
50-
$this->assertFileExists($backupFile);
51-
52-
@unlink($file);
53-
@unlink($backupFile);
54-
}
55-
5633
public function testDumpCreatesNestedDirectoriesAndFile()
5734
{
5835
$tempDir = sys_get_temp_dir();

src/Symfony/Component/Translation/Writer/TranslationWriter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function addDumper($format, DumperInterface $dumper)
4646
*/
4747
public function disableBackup()
4848
{
49+
// to be deprecated in 4.1
4950
foreach ($this->dumpers as $dumper) {
5051
if (method_exists($dumper, 'setBackup')) {
5152
$dumper->setBackup(false);

0 commit comments

Comments
 (0)