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
50 lines
1.3 KiB
<?php
|
|
|
|
namespace Zitec\RuleEngineBundle\Conditions;
|
|
|
|
/**
|
|
* Class CurrentTime
|
|
*/
|
|
class CurrentTime extends AbstractValueCondition
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $name = 'current_time';
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $label = 'Current Time';
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $description = 'Conditions for the current time';
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function getOperatorDefinitions(): array
|
|
{
|
|
return [
|
|
[
|
|
'label' => 'Time between',
|
|
'name' => $this::INTERVAL,
|
|
'fieldType' => 'datetime_interval',
|
|
'fieldOptions' => [
|
|
'datetimepicker' => [
|
|
'pickDate' => false,
|
|
'pickTime' => true,
|
|
'pick12HourFormat' => true,
|
|
'format' => 'HH:mm',
|
|
],
|
|
],
|
|
'value_transform' => function ($val) {
|
|
return [
|
|
'from' => strtotime('1970-01-01 ' . $val['from']),
|
|
'to' => strtotime('1970-01-01 ' . $val['to']),
|
|
];
|
|
},
|
|
],
|
|
];
|
|
}
|
|
}
|