Skip to content

Commit 606d2ea

Browse files
committed
[Translator][FileDumper] deprecated format method in favor of formatCatalogue.
1 parent 98fdb37 commit 606d2ea

13 files changed

+87
-1
lines changed

CHANGELOG.md

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

7+
* deprecated FileDumper::format(), overwrite FileDumper::formatCatalogue() instead.
78
* deprecated Translator::getMessages(), rely on TranslatorBagInterface::getCatalogue() instead.
89
* added option `json_encoding` to JsonFileDumper
910
* added options `as_tree`, `inline` to YamlFileDumper

Dumper/CsvFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ class CsvFileDumper extends FileDumper
2727
* {@inheritdoc}
2828
*/
2929
public function format(MessageCatalogue $messages, $domain = 'messages')
30+
{
31+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
32+
33+
return $this->formatCatalogue($messages, $domain);
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
3040
{
3141
$handle = fopen('php://memory', 'rb+');
3242

Dumper/FileDumper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public function dump(MessageCatalogue $messages, $options = array())
9999
*/
100100
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
101101
{
102+
@trigger_error('The '.__METHOD__.' method will replace the format method in 3.0. You should overwritten it instead of overwriting format instead.', E_USER_DEPRECATED);
103+
102104
return $this->format($messages, $domain);
103105
}
104106

@@ -109,6 +111,8 @@ protected function formatCatalogue(MessageCatalogue $messages, $domain, array $o
109111
* @param string $domain
110112
*
111113
* @return string representation
114+
*
115+
* @deprecated since version 2.8, to be removed in 3.0. Overwrite formatCatalogue() instead.
112116
*/
113117
abstract protected function format(MessageCatalogue $messages, $domain);
114118

Dumper/IcuResFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ class IcuResFileDumper extends FileDumper
2929
* {@inheritdoc}
3030
*/
3131
public function format(MessageCatalogue $messages, $domain = 'messages')
32+
{
33+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
34+
35+
return $this->formatCatalogue($messages, $domain);
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
3242
{
3343
$data = $indexes = $resources = '';
3444

Dumper/IniFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class IniFileDumper extends FileDumper
2424
* {@inheritdoc}
2525
*/
2626
public function format(MessageCatalogue $messages, $domain = 'messages')
27+
{
28+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
29+
30+
return $this->formatCatalogue($messages, $domain);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
2737
{
2838
$output = '';
2939

Dumper/JsonFileDumper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class JsonFileDumper extends FileDumper
2525
*/
2626
public function format(MessageCatalogue $messages, $domain = 'messages')
2727
{
28+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
29+
2830
return $this->formatCatalogue($messages, $domain);
2931
}
3032

Dumper/MoFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ class MoFileDumper extends FileDumper
2525
* {@inheritdoc}
2626
*/
2727
public function format(MessageCatalogue $messages, $domain = 'messages')
28+
{
29+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
30+
31+
return $this->formatCatalogue($messages, $domain);
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
2838
{
2939
$output = $sources = $targets = $sourceOffsets = $targetOffsets = '';
3040
$offsets = array();

Dumper/PhpFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class PhpFileDumper extends FileDumper
2424
* {@inheritdoc}
2525
*/
2626
protected function format(MessageCatalogue $messages, $domain)
27+
{
28+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
29+
30+
return $this->formatCatalogue($messages, $domain);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
2737
{
2838
$output = "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
2939

Dumper/PoFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class PoFileDumper extends FileDumper
2424
* {@inheritdoc}
2525
*/
2626
public function format(MessageCatalogue $messages, $domain = 'messages')
27+
{
28+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
29+
30+
return $this->formatCatalogue($messages, $domain);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
2737
{
2838
$output = 'msgid ""'."\n";
2939
$output .= 'msgstr ""'."\n";

Dumper/QtFileDumper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class QtFileDumper extends FileDumper
2424
* {@inheritdoc}
2525
*/
2626
public function format(MessageCatalogue $messages, $domain)
27+
{
28+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
29+
30+
return $this->formatCatalogue($messages, $domain);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
2737
{
2838
$dom = new \DOMDocument('1.0', 'utf-8');
2939
$dom->formatOutput = true;

0 commit comments

Comments
 (0)