Timezone.php 748 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * System config email field backend model
  8. */
  9. namespace Magento\Config\Model\Config\Backend\Locale;
  10. use Magento\Framework\Exception\LocalizedException;
  11. /**
  12. * @api
  13. * @since 100.0.2
  14. */
  15. class Timezone extends \Magento\Framework\App\Config\Value
  16. {
  17. /**
  18. * @return $this
  19. * @throws \Magento\Framework\Exception\LocalizedException
  20. */
  21. public function beforeSave()
  22. {
  23. if (!in_array($this->getValue(), \DateTimeZone::listIdentifiers(\DateTimeZone::ALL))) {
  24. throw new LocalizedException(__('The time zone is incorrect. Verify the time zone and try again.'));
  25. }
  26. return $this;
  27. }
  28. }