Skip to content
Browse files

Fix issue 9172

  • Loading branch information...
1 parent 8f8b20c commit 25f1d85d6b9004b50990af525a67bf9bf721df99 @umpirsky umpirsky committed with fabpot
View
1 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -5,6 +5,7 @@ CHANGELOG
-----
* Added `translation:debug` command
+ * Added `--no-backup` option to `translation:update` command
* Added `config:debug` command
* Added `yaml:lint` command
* Deprecated the `RouterApacheDumperCommand` which will be removed in Symfony 3.0.
View
8 src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
@@ -53,6 +53,10 @@ protected function configure()
'Should the update be done'
),
new InputOption(
+ 'no-backup', null, InputOption::VALUE_NONE,
+ 'Should backup be disabled'
+ ),
+ new InputOption(
'clean', null, InputOption::VALUE_NONE,
'Should clean not found messages'
)
@@ -139,6 +143,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
+ if ($input->getOption('no-backup') === true) {
+ $writer->disableBackup();
+ }
+
// save the files
if ($input->getOption('force') === true) {
$output->writeln('Writing files');
View
1 src/Symfony/Component/Translation/CHANGELOG.md
@@ -5,6 +5,7 @@ CHANGELOG
-----
* added relative file path template to the file dumpers
+ * added optional backup to the file dumpers
* changed IcuResFileDumper to extend FileDumper
2.3.0
View
21 src/Symfony/Component/Translation/Dumper/FileDumper.php
@@ -32,6 +32,13 @@
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.
*
* @param string $relativePathTemplate A template for the relative paths to files
@@ -42,6 +49,16 @@ public function setRelativePathTemplate($relativePathTemplate)
}
/**
+ * Sets backup flag.
+ *
+ * @param bool
+ */
+ public function setBackup($backup)
+ {
+ $this->backup = $backup;
+ }
+
+ /**
* {@inheritdoc}
*/
public function dump(MessageCatalogue $messages, $options = array())
@@ -55,7 +72,9 @@ public function dump(MessageCatalogue $messages, $options = array())
// backup
$fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
if (file_exists($fullpath)) {
- copy($fullpath, $fullpath.'~');
+ if ($this->backup) {
+ copy($fullpath, $fullpath.'~');
+ }
} else {
$directory = dirname($fullpath);
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
View
10 src/Symfony/Component/Translation/Writer/TranslationWriter.php
@@ -40,6 +40,16 @@ public function addDumper($format, DumperInterface $dumper)
}
/**
+ * Disables dumper backup.
+ */
+ public function disableBackup()
+ {
+ foreach ($this->dumpers as $dumper) {
+ $dumper->setBackup(false);
+ }
+ }
+
+ /**
* Obtains the list of supported formats.
*
* @return array

0 comments on commit 25f1d85

Please sign in to comment.
Something went wrong with that request. Please try again.