Exemplo n.º 1
0
 public function generateMapping(FieldType $fieldType, $withPipeline = false)
 {
     $type = $fieldType->getType();
     /** @var DataFieldType $dataFieldType */
     $dataFieldType = new $type();
     $out = $dataFieldType->generateMapping($fieldType, $withPipeline);
     $jsonName = $dataFieldType->getJsonName($fieldType);
     /** @var FieldType $child */
     foreach ($fieldType->getChildren() as $child) {
         if (!$child->getDeleted()) {
             if (isset($jsonName)) {
                 if (isset($out[$jsonName]["properties"])) {
                     $out[$jsonName]["properties"] = array_merge($out[$jsonName]["properties"], $this->generateMapping($child, $withPipeline));
                 } else {
                     $out[$jsonName] = array_merge($out[$jsonName], $this->generateMapping($child, $withPipeline));
                 }
             } else {
                 $out = array_merge($out, $this->generateMapping($child, $withPipeline));
             }
         }
     }
     return $out;
 }