Fix issue 9172
This commit is contained in:
parent
8f8b20c16f
commit
25f1d85d6b
@ -5,6 +5,7 @@ CHANGELOG
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
* Added `translation:debug` command
|
* Added `translation:debug` command
|
||||||
|
* Added `--no-backup` option to `translation:update` command
|
||||||
* Added `config:debug` command
|
* Added `config:debug` command
|
||||||
* Added `yaml:lint` command
|
* Added `yaml:lint` command
|
||||||
* Deprecated the `RouterApacheDumperCommand` which will be removed in Symfony 3.0.
|
* Deprecated the `RouterApacheDumperCommand` which will be removed in Symfony 3.0.
|
||||||
|
@ -52,6 +52,10 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
|||||||
'force', null, InputOption::VALUE_NONE,
|
'force', null, InputOption::VALUE_NONE,
|
||||||
'Should the update be done'
|
'Should the update be done'
|
||||||
),
|
),
|
||||||
|
new InputOption(
|
||||||
|
'no-backup', null, InputOption::VALUE_NONE,
|
||||||
|
'Should backup be disabled'
|
||||||
|
),
|
||||||
new InputOption(
|
new InputOption(
|
||||||
'clean', null, InputOption::VALUE_NONE,
|
'clean', null, InputOption::VALUE_NONE,
|
||||||
'Should clean not found messages'
|
'Should clean not found messages'
|
||||||
@ -139,6 +143,10 @@ EOF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($input->getOption('no-backup') === true) {
|
||||||
|
$writer->disableBackup();
|
||||||
|
}
|
||||||
|
|
||||||
// save the files
|
// save the files
|
||||||
if ($input->getOption('force') === true) {
|
if ($input->getOption('force') === true) {
|
||||||
$output->writeln('Writing files');
|
$output->writeln('Writing files');
|
||||||
|
@ -5,6 +5,7 @@ CHANGELOG
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
* added relative file path template to the file dumpers
|
* added relative file path template to the file dumpers
|
||||||
|
* added optional backup to the file dumpers
|
||||||
* changed IcuResFileDumper to extend FileDumper
|
* changed IcuResFileDumper to extend FileDumper
|
||||||
|
|
||||||
2.3.0
|
2.3.0
|
||||||
|
@ -31,6 +31,13 @@ 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.
|
||||||
*
|
*
|
||||||
@ -41,6 +48,16 @@ abstract class FileDumper implements DumperInterface
|
|||||||
$this->relativePathTemplate = $relativePathTemplate;
|
$this->relativePathTemplate = $relativePathTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets backup flag.
|
||||||
|
*
|
||||||
|
* @param bool
|
||||||
|
*/
|
||||||
|
public function setBackup($backup)
|
||||||
|
{
|
||||||
|
$this->backup = $backup;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -55,7 +72,9 @@ abstract class FileDumper implements DumperInterface
|
|||||||
// backup
|
// 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)) {
|
||||||
copy($fullpath, $fullpath.'~');
|
if ($this->backup) {
|
||||||
|
copy($fullpath, $fullpath.'~');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$directory = dirname($fullpath);
|
$directory = dirname($fullpath);
|
||||||
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
|
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
|
||||||
|
@ -39,6 +39,16 @@ class TranslationWriter
|
|||||||
$this->dumpers[$format] = $dumper;
|
$this->dumpers[$format] = $dumper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables dumper backup.
|
||||||
|
*/
|
||||||
|
public function disableBackup()
|
||||||
|
{
|
||||||
|
foreach ($this->dumpers as $dumper) {
|
||||||
|
$dumper->setBackup(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains the list of supported formats.
|
* Obtains the list of supported formats.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user