Exemple #1
0
 /**
  * @inheritdoc
  */
 public function build($conditions = null)
 {
     $values = $this->getValue();
     if (!is_array($values)) {
         $values = array($values);
         $this->setValue($values);
     }
     if (!ArrayUtils::isList($values)) {
         throw new InvalidConditionException('values must be an array without hash keys');
     }
     if (empty($values)) {
         throw new InvalidConditionException("values is empty");
     }
     return $this;
 }
Exemple #2
0
 /**
  * @inheritdoc
  * @return Order[]
  */
 public function build($conditions = null)
 {
     if (!is_array($this->condition)) {
         return array();
     }
     if (ArrayUtils::isList($this->condition)) {
         return array();
     }
     $result = array();
     foreach ($this->condition as $field => $condition) {
         try {
             $result[] = $this->buildOrder($field, $condition);
         } catch (InvalidConditionException $e) {
             continue;
         }
     }
     return $result;
 }
 /**
  * @inheritdoc
  * @return $this
  */
 public function build($conditions = null)
 {
     if (!in_array($this->group, $this->acceptedGroups)) {
         throw new InvalidConditionException('invalid group');
     }
     if ($this->dispatcher) {
         $this->dispatcher->dispatch(GroupEvent::EVENT_NAME, new GroupEvent($this->group));
     }
     $results = array();
     foreach ($this->parameters as $field => $values) {
         $operator = null;
         if (is_scalar($values) || ArrayUtils::isList($values)) {
             $values = [FilterCondition::CONDITION_EQ => $values];
         }
         //            if (is_array($values) && !ArrayUtils::isList($values)) {
         //                $operator = $condition;
         //            } else {
         //                $fieldValues = array($condition => $fieldValues);
         //            }
         foreach ($values as $operator => $value) {
             $builder = new FilterConditionBuilder();
             if ($operator !== null) {
                 $builder->setCompareOperator($operator);
             }
             $builder->setEventDispatcher($this->dispatcher);
             $builder->setConditions($field, $value);
             try {
                 $results[] = $builder->build();
             } catch (InvalidConditionException $e) {
                 continue;
             }
         }
     }
     $this->checkCondition($results);
     $this->conditions = $results;
     return $this;
 }