Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Conditions;
  3. /**
  4. * Class CurrentTime
  5. */
  6. class CurrentTime extends AbstractValueCondition
  7. {
  8. /**
  9. * @var string
  10. */
  11. protected $name = 'current_time';
  12. /**
  13. * @var string
  14. */
  15. protected $label = 'Current Time';
  16. /**
  17. * @var string
  18. */
  19. protected $description = 'Conditions for the current time';
  20. /**
  21. * @return array
  22. */
  23. protected function getOperatorDefinitions(): array
  24. {
  25. return [
  26. [
  27. 'label' => 'Time between',
  28. 'name' => $this::INTERVAL,
  29. 'fieldType' => 'datetime_interval',
  30. 'fieldOptions' => [
  31. 'datetimepicker' => [
  32. 'pickDate' => false,
  33. 'pickTime' => true,
  34. 'pick12HourFormat' => true,
  35. 'format' => 'HH:mm',
  36. ],
  37. ],
  38. 'value_transform' => function ($val) {
  39. return [
  40. 'from' => strtotime('1970-01-01 ' . $val['from']),
  41. 'to' => strtotime('1970-01-01 ' . $val['to']),
  42. ];
  43. },
  44. ],
  45. ];
  46. }
  47. }