示例#1
0
 /**
  * Apply filter by its type
  *
  * @param string $type
  * @param string $value
  * @return void
  */
 protected function applyFilterByType($type, $value)
 {
     if (!empty($value)) {
         $value = $this->wrappedComponent->convertDate($value);
         $filter = $this->filterBuilder->setConditionType($type)->setField($this->getName())->setValue($value->format('Y-m-d H:i:s'))->create();
         $this->getContext()->getDataProvider()->addFilter($filter);
     }
 }
示例#2
0
 /**
  * Apply filter
  *
  * @return void
  */
 protected function applyFilter()
 {
     if (isset($this->filterData[$this->getName()])) {
         $value = $this->filterData[$this->getName()];
         if (empty($value)) {
             return;
         }
         if (is_array($value)) {
             if (isset($value['from'])) {
                 $this->applyFilterByType('gteq', $this->wrappedComponent->convertDate($value['from']));
             }
             if (isset($value['to'])) {
                 $this->applyFilterByType('lteq', $this->wrappedComponent->convertDate($value['to'], 23, 59, 59));
             }
         } else {
             $this->applyFilterByType('eq', $this->wrappedComponent->convertDate($value));
         }
     }
 }
示例#3
0
文件: Date.php 项目: opexsw/magento2
 /**
  * Get condition
  *
  * @return array|null
  */
 protected function getCondition()
 {
     $value = isset($this->filterData[$this->getName()]) ? $this->filterData[$this->getName()] : null;
     if (!empty($value['from']) || !empty($value['to'])) {
         if (!empty($value['from'])) {
             $value['orig_from'] = $value['from'];
             $value['from'] = $this->wrappedComponent->convertDate($value['from'], $this->wrappedComponent->getLocale());
         } else {
             unset($value['from']);
         }
         if (!empty($value['to'])) {
             $value['orig_to'] = $value['to'];
             $value['to'] = $this->wrappedComponent->convertDate($value['to'], $this->wrappedComponent->getLocale());
         } else {
             unset($value['to']);
         }
         $value['datetime'] = true;
         $value['locale'] = $this->wrappedComponent->getLocale();
     } else {
         $value = null;
     }
     return $value;
 }