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.
 
 
 
 
 

56 lines
1.6 KiB

<?php
namespace Zitec\RuleEngineBundle\Conditions;
/**
* Class CurrentDate
*/
class CurrentDate extends AbstractValueCondition
{
/**
* @var string
*/
protected $name = 'current_date';
/**
* @var string
*/
protected $label = 'Current Date';
/**
* @var string
*/
protected $description = 'Conditions for the current date/time';
/**
* @return array
*/
protected function getOperatorDefinitions(): array
{
return [
[
'label' => 'date is after',
'name' => $this::GREATER,
'fieldType' => 'datetime',
'value_transform' => function ($val) {
return strtotime($val . ' + 1 day');
},
],
[
'label' => 'date is before',
'name' => $this::SMALLER,
'fieldType' => 'datetime',
'value_transform' => function ($val) {
return strtotime($val);
},
],
[
'label' => 'Date between',
'name' => $this::INTERVAL,
'fieldType' => 'datetime_interval',
'value_transform' => function ($val) {
return isset($val['from']) && isset($val['to']) ?
['from' => strtotime($val['from']), 'to' => strtotime($val['to'] . ' 23:59:59')] : null;
},
],
];
}
}