Skip to content

[Translator][FileDumper] deprecated format method in favor of formatCatalogue. #15699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/Translation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/CsvFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+');

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Translation/Dumper/FileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public function dump(MessageCatalogue $messages, $options = array())
*/
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);
}

Expand All @@ -109,6 +111,8 @@ protected function formatCatalogue(MessageCatalogue $messages, $domain, array $o
* @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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aitboudad this method should be implemented now (throwing an exception saying it must be implemented), to allow new child classes to implement only formatCatalogue and not both methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #15832 and thanks for the hint.


Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/IniFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Translation/Dumper/JsonFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/MoFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/PhpFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/PoFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Dumper/QtFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Translation/Dumper/XliffFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ protected function formatCatalogue(MessageCatalogue $messages, $domain, array $o
*/
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);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Translation/Dumper/YamlFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ protected function formatCatalogue(MessageCatalogue $messages, $domain, array $o
*/
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ public function testDumpCreatesNestedDirectoriesAndFile()

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';
Expand Down