8000 feature #10829 Fix issue 9172 (umpirsky) · symfony/symfony@9c1cdbd · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c1cdbd

Browse files
committed
feature #10829 Fix issue 9172 (umpirsky)
This PR was squashed before being merged into the 2.3-dev branch (closes #10829). Discussion ---------- Fix issue 9172 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9172 | License | MIT Commits ------- 25f1d85 Fix issue 9172
2 parents 8f8b20c + 25f1d85 commit 9c1cdbd

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* Added `translation:debug` command
8+
* Added `--no-backup` option to `translation:update` command
89
* Added `config:debug` command
910
* Added `yaml:lint` command
1011
* Deprecated the `RouterApacheDumperCommand` which will be removed in Symfony 3.0.

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ protected function configure()
5252
'force', null, InputOption::VALUE_NONE,
5353
'Should the update be done'
5454
),
55+
new InputOption(
56+
'no-backup', null, InputOption::VALUE_NONE,
57+
'Should backup be disabled'
58+
),
5559
new InputOption(
5660
'clean', null, InputOption::VALUE_NONE,
5761
'Should clean not found messages'
@@ -139,6 +143,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
139143
}
140144
}
141145

146+
if ($input->getOption('no-backup') === true) {
147+
$writer->disableBackup();
148+
}
149+
142150
// save the files
143151
if ($input->getOption('force') === true) {
144152
$output->writeln('Writing files');

src/Symfony/Component/Translation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* added relative file path template to the file dumpers
8+
* added optional backup to the file dumpers
89
* changed IcuResFileDumper to extend FileDumper
910

1011
2.3.0

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ abstract class FileDumper implements DumperInterface
3131
*/
3232
protected $relativePathTemplate = '%domain%.%locale%.%extension%';
3333

34+
/**
35+
* Make file backup before the dump.
36+
*
37+
* @var bool
38+
*/
39+
private $backup = true;
40+
3441
/**
3542
* Sets the template for the relative paths to files.
3643
*
@@ -41,6 +48,16 @@ public function setRelativePathTemplate($relativePathTemplate)
4148
$this->relativePathTemplate = $relativePathTemplate;
4249
}
4350

51+
/**
52+
* Sets backup flag.
53+
*
54+
* @param bool
55+
*/
56+
public function setBackup($backup)
57+
{
58+
$this->backup = $backup;
59+
}
60+
4461
/**
4562
* {@inheritdoc}
4663
*/
@@ -55,7 +72,9 @@ public function dump(MessageCatalogue $messages, $options = array())
5572
// backup
5673
$fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
5774
if (file_exists($fullpath)) {
58-
copy($fullpath, $fullpath.'~');
75+
if ($this->backup) {
76+
copy($fullpath, $fullpath.'~');
77+
}
5978
} else {
6079
$directory = dirname($fullpath);
6180
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public function addDumper($format, DumperInterface $dumper)
3939
$this->dumpers[$format] = $dumper;
4040
}
4141

42+
/**
43+
* Disables dumper backup.
44+
*/
45+
public function disableBackup()
46+
{
47+
foreach ($this->dumpers as $dumper) {
48+
$dumper->setBackup(false);
49+
}
50+
}
51+
4252
/**
4353
* Obtains the list of supported formats.
4454
*

0 commit comments

Comments
 (0)
0