コード例 #1
0
 /**
  * {@inheritdoc}
  *
  */
 public function setDataValue($input, DataField &$dataField, array $options)
 {
     $format = DateRangeFieldType::convertJavascriptDateFormat($options['displayOptions']['locale']['format']);
     $inputs = explode(' - ', $input);
     if (count($inputs) == 2) {
         $convertedDates = [];
         $fromConverted = \DateTime::createFromFormat($format, $inputs[0]);
         if ($fromConverted) {
             $convertedDates[$options['mappingOptions']['fromDateMachineName']] = $fromConverted->format(\DateTime::ISO8601);
         }
         $toConverted = \DateTime::createFromFormat($format, $inputs[1]);
         if ($toConverted) {
             $convertedDates[$options['mappingOptions']['toDateMachineName']] = $toConverted->format(\DateTime::ISO8601);
         }
         $dataField->setRawData($convertedDates);
     } else {
         //TODO: log warnign
     }
 }
コード例 #2
0
ファイル: AppExtension.php プロジェクト: theus77/ElasticMS
 public function convertJavascriptDateFormat($format)
 {
     return DateRangeFieldType::convertJavascriptDateFormat($format);
 }