feature #15699 [Translator][FileDumper] deprecated format method in favor of formatCatalogue. (aitboudad)
This PR was merged into the 2.8 branch.
Discussion
----------
[Translator][FileDumper] deprecated format method in favor of formatCatalogue.
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Fixed tickets | ~
| Tests pass? | yes
| License | MIT
We introduced `formatCatalogue` to allow using options passed to the dump method.
Commits
-------
366879b
[Translator][FileDumper] deprecated format method in favor of formatCatalogue.
This commit is contained in:
commit
327c647be5
@ -4,6 +4,7 @@ CHANGELOG
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
* deprecated FileDumper::format(), overwrite FileDumper::formatCatalogue() instead.
|
||||
* deprecated Translator::getMessages(), rely on TranslatorBagInterface::getCatalogue() instead.
|
||||
* added option `json_encoding` to JsonFileDumper
|
||||
* added options `as_tree`, `inline` to YamlFileDumper
|
||||
|
@ -27,6 +27,16 @@ class CsvFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$handle = fopen('php://memory', 'rb+');
|
||||
|
||||
|
@ -99,6 +99,8 @@ abstract class FileDumper implements DumperInterface
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->format($messages, $domain);
|
||||
}
|
||||
|
||||
@ -109,6 +111,8 @@ abstract class FileDumper implements DumperInterface
|
||||
* @param string $domain
|
||||
*
|
||||
* @return string representation
|
||||
*
|
||||
* @deprecated since version 2.8, to be removed in 3.0. Overwrite formatCatalogue() instead.
|
||||
*/
|
||||
abstract protected function format(MessageCatalogue $messages, $domain);
|
||||
|
||||
|
@ -29,6 +29,16 @@ class IcuResFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$data = $indexes = $resources = '';
|
||||
|
||||
|
@ -24,6 +24,16 @@ class IniFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = '';
|
||||
|
||||
|
@ -25,6 +25,8 @@ class JsonFileDumper extends FileDumper
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,16 @@ class MoFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = $sources = $targets = $sourceOffsets = $targetOffsets = '';
|
||||
$offsets = array();
|
||||
|
@ -24,6 +24,16 @@ class PhpFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function format(MessageCatalogue $messages, $domain)
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
|
||||
|
||||
|
@ -24,6 +24,16 @@ class PoFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$output = 'msgid ""'."\n";
|
||||
$output .= 'msgstr ""'."\n";
|
||||
|
@ -24,6 +24,16 @@ class QtFileDumper extends FileDumper
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain)
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
$dom->formatOutput = true;
|
||||
|
@ -51,6 +51,8 @@ class XliffFileDumper extends FileDumper
|
||||
*/
|
||||
protected function format(MessageCatalogue $messages, $domain)
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ class YamlFileDumper extends FileDumper
|
||||
*/
|
||||
protected function format(MessageCatalogue $messages, $domain)
|
||||
{
|
||||
@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);
|
||||
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,16 @@ class FileDumperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
class ConcreteFileDumper extends FileDumper
|
||||
{
|
||||
protected function format(MessageCatalogue $messages, $domain)
|
||||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function format(MessageCatalogue $messages, $domain)
|
||||
{
|
||||
return $this->formatCatalogue($messages, $domain);
|
||||
}
|
||||
|
||||
protected function getExtension()
|
||||
{
|
||||
return 'concrete';
|
||||
|
Reference in New Issue
Block a user