Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CurrencyDisplayOptions.php
Go to the documentation of this file.
1 <?php
7 
10 
12 {
16  protected $symbolFactory;
17 
21  public function __construct(\Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory)
22  {
23  $this->symbolFactory = $symbolFactory;
24  }
25 
32  public function execute(\Magento\Framework\Event\Observer $observer)
33  {
34  $baseCode = $observer->getEvent()->getBaseCode();
35  $currencyOptions = $observer->getEvent()->getCurrencyOptions();
36  $currencyOptions->addData($this->getCurrencyOptions($baseCode));
37 
38  return $this;
39  }
40 
47  protected function getCurrencyOptions($baseCode)
48  {
49  $currencyOptions = [];
50  if ($baseCode) {
51  $customCurrencySymbol = $this->symbolFactory->create()->getCurrencySymbol($baseCode);
52  if ($customCurrencySymbol) {
53  $currencyOptions[Currency::CURRENCY_OPTION_SYMBOL] = $customCurrencySymbol;
55  }
56  }
57 
58  return $currencyOptions;
59  }
60 }
execute(\Magento\Framework\Event\Observer $observer)
const USE_SYMBOL
Definition: Currency.php:41
__construct(\Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory)