Skip to content

Commit

Permalink
feature #22879 [Translation] remove deprecated features (xabbuh)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed May 25, 2017
2 parents ad2c9f0 + 3a03de0 commit d741908
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 39 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Component/Translation/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.0.0
-----

* removed the backup feature of the `FileDumper` class

3.2.0
-----

Expand Down
23 changes: 7 additions & 16 deletions src/Symfony/Component/Translation/Dumper/FileDumper.php
Expand Up @@ -17,7 +17,6 @@

/**
* 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
Expand All @@ -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.
*
Expand All @@ -57,7 +49,12 @@ public function setRelativePathTemplate($relativePathTemplate)
*/
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
}

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

// 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));
Expand Down
23 changes: 0 additions & 23 deletions src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php
Expand Up @@ -30,29 +30,6 @@ public function testDump()
$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();
Expand Down
Expand Up @@ -46,6 +46,7 @@ public function addDumper($format, DumperInterface $dumper)
*/
public function disableBackup()
{
// to be deprecated in 4.1
foreach ($this->dumpers as $dumper) {
if (method_exists($dumper, 'setBackup')) {
$dumper->setBackup(false);
Expand Down

0 comments on commit d741908

Please sign in to comment.