Exemplo n.º 1
0
 private function processGroups(\SimpleXMLElement $values, ValuesGroup $valuesGroup, $groupIdx, $level)
 {
     $this->validateGroupsCount($groupIdx, $values->groups->children()->count(), $level);
     $index = 0;
     foreach ($values->groups->children() as $element) {
         $subValuesGroup = new ValuesGroup(isset($element['logical']) ? (string) $element['logical'] : ValuesGroup::GROUP_LOGICAL_AND);
         $this->processGroup($element, $subValuesGroup, $index, $level + 1);
         $valuesGroup->addGroup($subValuesGroup);
         ++$index;
     }
 }
Exemplo n.º 2
0
 /**
  * Create a new ValuesGroup and returns the object instance.
  *
  * After creating the group it can be expended with fields or subgroups:
  *
  * ->group()
  *     ->field('name')
  *         ->...
  *     ->end() // return back to the ValuesGroup.
  * ->end() // return back to the parent ValuesGroup
  *
  * @param string $logical eg. one of the following ValuesGroup class constants value:
  *                        GROUP_LOGICAL_OR or GROUP_LOGICAL_AND
  *
  * @return SearchConditionBuilder
  */
 public function group($logical = ValuesGroup::GROUP_LOGICAL_AND)
 {
     $builder = new self($logical, null, $this);
     $this->valuesGroup->addGroup($builder->getGroup());
     return $builder;
 }
Exemplo n.º 3
0
 /**
  * {FieldIdentification ":" FieldValues}*.
  *
  * @param ValuesGroup $valuesGroup
  * @param int         $level
  * @param int         $groupIdx
  * @param bool        $inGroup
  */
 private function fieldValuesPairs(ValuesGroup $valuesGroup, $level = 0, $groupIdx = 0, $inGroup = false)
 {
     $groupCount = 0;
     while (null !== $this->lexer->lookahead) {
         switch ($this->lexer->lookahead['type']) {
             case Lexer::T_OPEN_PARENTHESIS:
             case Lexer::T_MULTIPLY:
                 $groupCount++;
                 $this->validateGroupsCount($groupIdx, $groupCount, $level);
                 $valuesGroup->addGroup($this->fieldGroup($level + 1, $groupCount - 1));
                 break;
             case Lexer::T_IDENTIFIER:
                 $fieldName = $this->getFieldName($this->fieldIdentification());
                 $fieldConfig = $this->config->getFieldSet()->get($fieldName);
                 if ($valuesGroup->hasField($fieldName)) {
                     $this->fieldValues($fieldConfig, $valuesGroup->getField($fieldName), $level, $groupIdx);
                 } else {
                     $valuesGroup->addField($fieldName, $this->fieldValues($fieldConfig, new ValuesBag(), $level, $groupIdx));
                 }
                 break;
             case $inGroup && Lexer::T_CLOSE_PARENTHESIS:
                 // Group closing is handled using the Group() method
                 break 2;
             default:
                 $this->syntaxError(['(', 'FieldIdentification']);
                 break;
         }
     }
 }
Exemplo n.º 4
0
 private function processGroups(array $groups, ValuesGroup $valuesGroup, $level)
 {
     foreach ($groups as $index => $values) {
         $subValuesGroup = new ValuesGroup(isset($values['logical-case']) ? $values['logical-case'] : ValuesGroup::GROUP_LOGICAL_AND);
         $this->processGroup($values, $subValuesGroup, $index, $level + 1);
         $valuesGroup->addGroup($subValuesGroup);
     }
 }