From 2869a32cf11811af1c8feeb0e51aac5ea8fffc9a Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Mon, 4 May 2015 14:40:06 +0000 Subject: [PATCH] [Translator] deprecate getMessages in favor of getCatalogue. --- UPGRADE-2.8.md | 24 +++++++++++++++++++ .../Component/Translation/CHANGELOG.md | 4 ++++ .../Translation/Tests/TranslatorTest.php | 3 ++- .../Component/Translation/Translator.php | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 UPGRADE-2.8.md diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md new file mode 100644 index 0000000000000..07c336c7c2ba0 --- /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 157752ca77180..35f4087459dc3 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 3ee9be019dd25..ec06e50b0d62b 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 7ed987d41ee8d..d9466cb07a914 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