Interval.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Dotdigitalgroup\Email\Model\Config\Source\Carts;
  3. class Interval implements \Magento\Framework\Data\OptionSourceInterface
  4. {
  5. /**
  6. * Available times.
  7. *
  8. * @var array
  9. */
  10. private $times
  11. = [
  12. 1,
  13. 2,
  14. 3,
  15. 4,
  16. 5,
  17. 6,
  18. 12,
  19. 24,
  20. 36,
  21. 48,
  22. 60,
  23. 72,
  24. 84,
  25. 96,
  26. 108,
  27. 120,
  28. 240,
  29. ];
  30. /**
  31. * Send to campain options hours.
  32. *
  33. * @return array
  34. */
  35. public function toOptionArray()
  36. {
  37. $result = $row = [];
  38. $i = 0;
  39. foreach ($this->times as $one) {
  40. if ($i == 0) {
  41. $row = [
  42. 'value' => $one,
  43. 'label' => $one . __(' Hour'),
  44. ];
  45. } else {
  46. $row = [
  47. 'value' => $one,
  48. 'label' => $one . __(' Hours'),
  49. ];
  50. }
  51. $result[] = $row;
  52. ++$i;
  53. }
  54. return $result;
  55. }
  56. }