[Translation] remove deprecated features
This commit is contained in:
parent
da61abdf20
commit
3a03de0787
@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* removed the backup feature of the `FileDumper` class
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
|
@ -17,7 +17,6 @@ use Symfony\Component\Translation\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s).
|
||||
* Performs backup of already existing files.
|
||||
*
|
||||
* Options:
|
||||
* - path (mandatory): the directory where the files should be saved
|
||||
@ -33,13 +32,6 @@ abstract class FileDumper implements DumperInterface
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -57,7 +49,12 @@ abstract class FileDumper implements DumperInterface
|
||||
*/
|
||||
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
|
||||
foreach ($messages->getDomains() as $domain) {
|
||||
// backup
|
||||
$fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
|
||||
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 {
|
||||
if (!file_exists($fullpath)) {
|
||||
$directory = dirname($fullpath);
|
||||
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
|
||||
throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory));
|
||||
|
@ -30,29 +30,6 @@ class FileDumperTest extends TestCase
|
||||
$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()
|
||||
{
|
||||
$tempDir = sys_get_temp_dir();
|
||||
|
@ -46,6 +46,7 @@ class TranslationWriter
|
||||
*/
|
||||
public function disableBackup()
|
||||
{
|
||||
// to be deprecated in 4.1
|
||||
foreach ($this->dumpers as $dumper) {
|
||||
if (method_exists($dumper, 'setBackup')) {
|
||||
$dumper->setBackup(false);
|
||||
|
Reference in New Issue
Block a user