Priority.php 665 B

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sitemap\Model\Config\Backend;
  7. class Priority extends \Magento\Framework\App\Config\Value
  8. {
  9. /**
  10. * @return $this
  11. * @throws \Exception
  12. */
  13. public function beforeSave()
  14. {
  15. $value = $this->getValue();
  16. if ($value < 0 || $value > 1) {
  17. throw new \Exception(__('The priority must be between 0 and 1.'));
  18. } elseif ($value == 0 && !($value === '0' || $value === '0.0')) {
  19. throw new \Exception(__('The priority must be between 0 and 1.'));
  20. }
  21. return $this;
  22. }
  23. }