All.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Model\Config\Source\Locale\Currency;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class All implements \Magento\Framework\Option\ArrayInterface
  12. {
  13. /**
  14. * @var array
  15. */
  16. protected $_options;
  17. /**
  18. * @var \Magento\Framework\Locale\ListsInterface
  19. */
  20. protected $_localeLists;
  21. /**
  22. * @param \Magento\Framework\Locale\ListsInterface $localeLists
  23. */
  24. public function __construct(\Magento\Framework\Locale\ListsInterface $localeLists)
  25. {
  26. $this->_localeLists = $localeLists;
  27. }
  28. /**
  29. * @param bool $isMultiselect
  30. * @return array
  31. */
  32. public function toOptionArray($isMultiselect = false)
  33. {
  34. if (!$this->_options) {
  35. $this->_options = $this->_localeLists->getOptionAllCurrencies();
  36. }
  37. $options = $this->_options;
  38. if (!$isMultiselect) {
  39. array_unshift($options, ['value' => '', 'label' => '']);
  40. }
  41. return $options;
  42. }
  43. }