diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md new file mode 100644 index 000000000000..07c336c7c2ba --- /dev/null +++ b/UPGRADE-2.8.md @@ -0,0 +1,24 @@ +UPGRADE FROM 2.7 to 2.8 +======================= + +Translator +---------- + * The `getMessages()` method of the `Symfony\Component\Translation\Translator` was deprecated and will be removed in + Symfony 3.0. You should use the `getCatalogue()` method of the `Symfony\Component\Translation\TranslatorBagInterface`. + + Before: + + ```php + $messages = $translator->getMessages(); + ``` + + After: + + ```php + $catalogue = $translator->getCatalogue($locale); + $messages = $catalogue->all(); + + while ($catalogue = $catalogue->getFallbackCatalogue()) { + $messages = array_replace_recursive($catalogue->all(), $messages); + } + ``` diff --git a/src/Symfony/Component/Translation/CHANGELOG.md b/src/Symfony/Component/Translation/CHANGELOG.md index 157752ca7718..35f4087459dc 100644 --- a/src/Symfony/Component/Translation/CHANGELOG.md +++ b/src/Symfony/Component/Translation/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========= +2.8.0 +----- + * deprecated Translator::getMessages(), rely on the TranslatorBagInterface::getCatalogue() method instead. + 2.7.0 ----- diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 3ee9be019dd2..ec06e50b0d62 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -497,9 +497,10 @@ public function testTransChoiceFallbackWithNoTranslation() } /** + * @group legacy * @dataProvider dataProviderGetMessages */ - public function testGetMessages($resources, $locale, $expected) + public function testLegacyGetMessages($resources, $locale, $expected) { $locales = array_keys($resources); $_locale = !is_null($locale) ? $locale : reset($locales); diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 7ed987d41ee8..d9466cb07a91 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -292,6 +292,8 @@ protected function getLoaders() */ public function getMessages($locale = null) { + trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Rely on the TranslatorBagInterface::getCatalogue() method instead', E_USER_DEPRECATED); + $catalogues = array(); $catalogues[] = $catalogue = $this->getCatalogue($locale); while ($catalogue = $catalogue->getFallbackCatalogue()) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy