Exemplo n.º 1
0
 /**
  * Build XML for an add command
  *
  * @param Solarium_Query_Update_Command_Add $command
  * @return string
  */
 public function buildAddXml($command)
 {
     $xml = '<add';
     $xml .= $this->boolAttrib('overwrite', $command->getOverwrite());
     $xml .= $this->attrib('commitWithin', $command->getCommitWithin());
     $xml .= '>';
     foreach ($command->getDocuments() as $doc) {
         $xml .= '<doc';
         $xml .= $this->attrib('boost', $doc->getBoost());
         $xml .= '>';
         foreach ($doc->getFields() as $name => $value) {
             $boost = $doc->getFieldBoost($name);
             $modifier = $doc instanceof Solarium_Document_AtomicUpdate ? $doc->getModifierForField($name) : null;
             if (is_array($value)) {
                 foreach ($value as $multival) {
                     $xml .= $this->_buildFieldXml($name, $boost, $multival, $modifier);
                 }
             } else {
                 $xml .= $this->_buildFieldXml($name, $boost, $value, $modifier);
             }
         }
         $xml .= '</doc>';
     }
     $xml .= '</add>';
     return $xml;
 }
Exemplo n.º 2
0
 /**
  * Build XML for an add command
  *
  * @param Solarium_Query_Update_Command_Add $command
  * @return string
  */
 public function buildAddXml($command)
 {
     $xml = '<add';
     $xml .= $this->boolAttrib('overwrite', $command->getOverwrite());
     $xml .= $this->attrib('commitWithin', $command->getCommitWithin());
     $xml .= '>';
     foreach ($command->getDocuments() as $doc) {
         $xml .= '<doc';
         $xml .= $this->attrib('boost', $doc->getBoost());
         $xml .= '>';
         foreach ($doc->getFields() as $name => $value) {
             $boost = $doc->getFieldBoost($name);
             if (is_array($value)) {
                 foreach ($value as $multival) {
                     $xml .= $this->_buildFieldXml($name, $boost, $multival);
                 }
             } else {
                 $xml .= $this->_buildFieldXml($name, $boost, $value);
             }
         }
         $xml .= '</doc>';
     }
     $xml .= '</add>';
     return $xml;
 }