Esempio n. 1
0
 private function removeDuplicatesInGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet)
 {
     foreach ($valuesGroup->getFields() as $fieldName => $values) {
         $this->removeDuplicatesInValuesBag($fieldSet->get($fieldName), $values);
     }
     // Traverse the subgroups.
     foreach ($valuesGroup->getGroups() as $group) {
         $this->removeDuplicatesInGroup($group, $fieldSet);
     }
 }
Esempio n. 2
0
 /**
  * @param ValuesGroup $valuesGroup
  * @param FieldSet    $fieldSet
  */
 private function normalizeRangesInGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet)
 {
     foreach ($valuesGroup->getFields() as $fieldName => $values) {
         $config = $fieldSet->get($fieldName);
         if ($values->has(Range::class) || $values->has(ExcludedRange::class)) {
             $this->normalizeRangesInValuesBag($config, $values);
         }
     }
     foreach ($valuesGroup->getGroups() as $group) {
         $this->normalizeRangesInGroup($group, $fieldSet);
     }
 }
Esempio n. 3
0
 /**
  * @param ValuesGroup $valuesGroup
  * @param FieldSet    $fieldSet
  */
 private function optimizeValuesInGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet)
 {
     foreach ($valuesGroup->getFields() as $fieldName => $values) {
         if (!isset($this->comparators[$fieldName])) {
             continue;
         }
         $config = $fieldSet->get($fieldName);
         if ($values->hasSimpleValues() || $values->hasExcludedSimpleValues()) {
             $this->optimizeValuesInValuesBag($config, $this->comparators[$fieldName], $values);
         }
     }
     // Traverse the subgroups.
     foreach ($valuesGroup->getGroups() as $group) {
         $this->optimizeValuesInGroup($group, $fieldSet);
     }
 }
 private function processFields()
 {
     $fields = [];
     foreach ($this->fields as $fieldName => $field) {
         $fields[$fieldName] = new QueryField($this->fieldSet->get($fieldName), $field['db_type'], $field['alias'], $field['column'], isset($this->fieldConversions[$fieldName]) ? $this->fieldConversions[$fieldName] : null, isset($this->valueConversions[$fieldName]) ? $this->valueConversions[$fieldName] : null);
     }
     foreach ($this->combinedFields as $fieldName => $subFieldsConfig) {
         $subsFieldNames = [];
         foreach ($subFieldsConfig as $n => $field) {
             $fieldNameN = $fieldName . '#' . $n;
             $subsFieldNames[] = $fieldNameN;
             $fields[$fieldNameN] = new QueryField($field['field'], $field['db_type'], $field['alias'], $field['column'], isset($this->fieldConversions[$fieldName]) ? $this->fieldConversions[$fieldName] : null, isset($this->valueConversions[$fieldName]) ? $this->valueConversions[$fieldName] : null);
         }
         $fields[$fieldName] = $subsFieldNames;
     }
     return $fields;
 }
Esempio n. 5
0
 /**
  * @param ValuesGroup $valuesGroup
  * @param FieldSet    $fieldSet
  * @param bool        $isRoot
  *
  * @return array
  */
 protected function exportGroup(ValuesGroup $valuesGroup, FieldSet $fieldSet, $isRoot = false)
 {
     $result = [];
     $fields = $valuesGroup->getFields();
     foreach ($fields as $name => $values) {
         if (0 === $values->count()) {
             continue;
         }
         $exportedValue = $this->exportValues($values, $fieldSet->get($name));
         // Only export fields with actual values.
         if (count($exportedValue) > 0) {
             $fieldLabel = $this->labelResolver->resolveFieldLabel($fieldSet, $name);
             $result['fields'][$fieldLabel] = $exportedValue;
         }
     }
     foreach ($valuesGroup->getGroups() as $group) {
         $result['groups'][] = $this->exportGroup($group, $fieldSet, false);
     }
     if (isset($result['fields']) && ValuesGroup::GROUP_LOGICAL_OR === $valuesGroup->getGroupLogical()) {
         $result['logical-case'] = 'OR';
     }
     return $result;
 }