Address.php 830 B

12345678910111213141516171819202122232425262728293031323334
  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\Email;
  10. use Magento\Framework\Exception\LocalizedException;
  11. /**
  12. * @api
  13. * @since 100.0.2
  14. */
  15. class Address extends \Magento\Framework\App\Config\Value
  16. {
  17. /**
  18. * @return $this
  19. * @throws \Magento\Framework\Exception\LocalizedException
  20. */
  21. public function beforeSave()
  22. {
  23. $value = $this->getValue();
  24. if (!\Zend_Validate::is($value, \Magento\Framework\Validator\EmailAddress::class)) {
  25. throw new LocalizedException(
  26. __('The "%1" email address is incorrect. Verify the email address and try again.', $value)
  27. );
  28. }
  29. return $this;
  30. }
  31. }