Timezone.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Locale timezone source
  8. */
  9. namespace Magento\Config\Model\Config\Source\Locale;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Timezone implements \Magento\Framework\Option\ArrayInterface
  15. {
  16. /**
  17. * Timezones that works incorrect with php_intl extension
  18. */
  19. protected $ignoredTimezones = [
  20. 'Antarctica/Troll',
  21. 'Asia/Chita',
  22. 'Asia/Srednekolymsk',
  23. 'Pacific/Bougainville'
  24. ];
  25. /**
  26. * @var \Magento\Framework\Locale\ListsInterface
  27. */
  28. protected $_localeLists;
  29. /**
  30. * @param \Magento\Framework\Locale\ListsInterface $localeLists
  31. */
  32. public function __construct(\Magento\Framework\Locale\ListsInterface $localeLists)
  33. {
  34. $this->_localeLists = $localeLists;
  35. }
  36. /**
  37. * @return array
  38. */
  39. public function toOptionArray()
  40. {
  41. $timezones = $this->_localeLists->getOptionTimezones();
  42. $timezones = array_filter($timezones, function ($value) {
  43. if (in_array($value['value'], $this->ignoredTimezones)) {
  44. return false;
  45. }
  46. return true;
  47. });
  48. return $timezones;
  49. }
  50. }