From 3293254f23aa47a2b5bb8e54901ae9f296031727 Mon Sep 17 00:00:00 2001 From: Ricardo Martins Date: Wed, 21 Feb 2018 20:29:08 +1100 Subject: [PATCH 1/3] Remove non-allowed currencies from the currencies dropdown in the Magento Setup --- lib/internal/Magento/Framework/Setup/Lists.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/internal/Magento/Framework/Setup/Lists.php b/lib/internal/Magento/Framework/Setup/Lists.php index ce0dd8348acc3..b437969c0af09 100644 --- a/lib/internal/Magento/Framework/Setup/Lists.php +++ b/lib/internal/Magento/Framework/Setup/Lists.php @@ -21,12 +21,20 @@ class Lists */ protected $allowedLocales; + /** + * List of allowed currencies + * + * @var array + */ + protected $allowedCurrencies; + /** * @param ConfigInterface $localeConfig */ public function __construct(ConfigInterface $localeConfig) { $this->allowedLocales = $localeConfig->getAllowedLocales(); + $this->allowedCurrencies = $localeConfig->getAllowedCurrencies(); } /** @@ -64,6 +72,10 @@ public function getCurrencyList() $currencies = (new CurrencyBundle())->get(Resolver::DEFAULT_LOCALE)['Currencies']; $list = []; foreach ($currencies as $code => $data) { + $isAllowedCurrency = array_search($code, $this->allowedCurrencies) !== false; + if (!$isAllowedCurrency) { + continue; + } $list[$code] = $data[1] . ' (' . $code . ')'; } asort($list); From a92a3b2e50738e89b0ea423f6f1d0f16b0ad7fff Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Thu, 22 Feb 2018 13:20:19 +0200 Subject: [PATCH 2/3] [Forwardport] Remove not-allowed currencies from the currencies dropdown in Setup. Cover code changes with unit test. --- .../Magento/Framework/Setup/Test/Unit/ListsTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php index 6e7ca3ece43b1..a25771b4519f2 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php @@ -58,6 +58,9 @@ protected function setUp() $this->mockConfig->expects($this->any()) ->method('getAllowedLocales') ->willReturn($this->expectedLocales); + $this->mockConfig->expects($this->any()) + ->method('getAllowedCurrencies') + ->willReturn($this->expectedCurrencies); $this->lists = new Lists($this->mockConfig); } @@ -73,4 +76,13 @@ public function testGetLocaleList() $locales = array_intersect($this->expectedLocales, array_keys($this->lists->getLocaleList())); $this->assertEquals($this->expectedLocales, $locales); } + + /** + * Test Lists:getCurrencyList() considering allowed currencies config values. + */ + public function testGetCurrencyList() + { + $currencies = array_intersect($this->expectedCurrencies, array_keys($this->lists->getCurrencyList())); + $this->assertEquals($this->expectedCurrencies, $currencies); + } } From ef94d4436a24bf42909beceddcdd4e857ca51dd8 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Tue, 6 Mar 2018 10:59:55 +0200 Subject: [PATCH 3/3] Setup Lists - Make allowedCurrencies property private This property was introduced in b1a5bc1 with protected visibility --- lib/internal/Magento/Framework/Setup/Lists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Setup/Lists.php b/lib/internal/Magento/Framework/Setup/Lists.php index b437969c0af09..1ee5baf28658e 100644 --- a/lib/internal/Magento/Framework/Setup/Lists.php +++ b/lib/internal/Magento/Framework/Setup/Lists.php @@ -26,7 +26,7 @@ class Lists * * @var array */ - protected $allowedCurrencies; + private $allowedCurrencies; /** * @param ConfigInterface $localeConfig