<?php
 namespace App\OfferProfileRules; class Criterion_OfferStartDate extends CriterionAbstract { public function __construct($operation, $startValue, $endValue) { parent::__construct($operation, ['start'=>$startValue, 'end'=>$endValue]); } public function checkFields(\App\OfferProfileRules\Fields $fields) { return $this->checkField($fields->offerStartDate); } public function checkAssignedValues(\App\MessagesCollector $msgs) { if ($this->values['start'] and !validDate($this->values['start'])) { $msgs->addWarning('The start date is not valid.'); } if ($this->values['end'] and !validDate($this->values['end'])) { $msgs->addWarning('The end date is not valid.'); } if (!$this->values['start'] and !$this->values['end']) { $msgs->addWarning('At least the beginning or the end of the offer start date must be set.'); } } protected function createDescription_getEntityName($code) { return \Engine\DateTime::createFromIsoDate($code)->formatDateStd(); } } 