Example #1
0
 /**
  *
  * {@inheritdoc}
  *
  */
 public static function generateMapping(FieldType $current, $withPipeline)
 {
     if (!empty($current->getMappingOptions()) && !empty($current->getMappingOptions()['mappingOptions'])) {
         return [$current->getName() => $current->getMappingOptions()['mappingOptions']];
     }
     return [];
 }
Example #2
0
 private function createFieldType($contentType, $parent, $type, $name, $label, $deleted, $orderKey, $many, $editOptions)
 {
     $fieldType = new FieldType();
     if ($parent != '') {
         $fieldType->setParent($this->getReference($parent));
     } else {
         $fieldType->setContentType($this->getReference($contentType));
         $this->getReference($contentType)->setFieldType($fieldType);
     }
     $fieldType->setType('AppBundle\\Form\\DataField\\' . $type . 'Type');
     $fieldType->setName($name);
     $fieldType->setLabel($label);
     $fieldType->setDeleted($deleted);
     $fieldType->setOrderKey($orderKey);
     $fieldType->setMany($many);
     $fieldType->setEditOptions($editOptions);
     return $fieldType;
 }
Example #3
0
 function __construct()
 {
     $this->templates = new \Doctrine\Common\Collections\ArrayCollection();
     $this->views = new \Doctrine\Common\Collections\ArrayCollection();
     $this->dirty = true;
     $this->editTwigWithWysiwyg = true;
     $fieldType = new FieldType();
     $fieldType->setName('source');
     //      	$fieldType->setDeleted ( false );
     //      	$fieldType->setOrderKey( false );
     $fieldType->setType(ContainerFieldType::class);
     $fieldType->setContentType($this);
     $this->setFieldType($fieldType);
     $this->setAskForOuuid(true);
 }
 /**
  * Try to find (recursively) if there is a container where subfields must be reordered in the content type
  *
  * @param array $formArray
  * @param FieldType $fieldType
  */
 private function reorderFields(array $formArray, FieldType $fieldType)
 {
     if (array_key_exists('reorder', $formArray)) {
         $keys = array_keys($formArray);
         /** @var FieldType $child */
         foreach ($fieldType->getChildren() as $child) {
             if (!$child->getDeleted()) {
                 $child->setOrderKey(array_search('ems_' . $child->getName(), $keys));
             }
         }
         $this->addFlash('notice', 'Subfields in ' . $fieldType->getName() . ' has been prepared to be reordered');
         return true;
     } else {
         /** @var FieldType $child */
         foreach ($fieldType->getChildren() as $child) {
             if (!$child->getDeleted() && $this->reorderFields($formArray['ems_' . $child->getName()], $child)) {
                 return true;
             }
         }
     }
     return false;
 }
Example #5
0
 public function updateDataStructure(FieldType $meta)
 {
     //no need to generate the structure for subfields (
     $isContainer = true;
     if (null !== $this->getFieldType()) {
         $type = $this->getFieldType()->getType();
         $datFieldType = new $type();
         $isContainer = $datFieldType->isContainer();
     }
     if ($isContainer) {
         /** @var FieldType $field */
         foreach ($meta->getChildren() as $field) {
             //no need to generate the structure for delete field
             if (!$field->getDeleted()) {
                 $child = $this->__get('ems_' . $field->getName());
                 if (null == $child) {
                     $child = new DataField();
                     $child->setFieldType($field);
                     $child->setOrderKey($field->getOrderKey());
                     $child->setParent($this);
                     $this->addChild($child);
                     if (isset($field->getDisplayOptions()['defaultValue'])) {
                         $child->setEncodedText($field->getDisplayOptions()['defaultValue']);
                     }
                 }
                 if (strcmp($field->getType(), CollectionFieldType::class) != 0) {
                     $child->updateDataStructure($field);
                 }
             }
         }
     }
 }
Example #6
0
 /**
  * Build an elasticsearch mapping options as an array
  * 
  * @param array $options
  * @param FieldType $current
  */
 public static function generateMapping(FieldType $current, $withPipeline)
 {
     return [$current->getName() => array_merge(["type" => "string"], array_filter($current->getMappingOptions()))];
 }
Example #7
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;
 }
 /**
  *
  * {@inheritdoc}
  *
  */
 public static function generateMapping(FieldType $current, $withPipeline)
 {
     return [$current->getName() => ['type' => 'nested', 'properties' => []]];
 }
 /**
  * {@inheritdoc}
  */
 public static function generatePipeline(FieldType $current)
 {
     return ["attachment" => ['field' => $current->getName() . '.content', 'target_field' => $current->getName() . '.attachment', 'indexed_chars' => 1000000]];
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public static function generateMapping(FieldType $current, $withPipeline)
 {
     return [$current->getName() => array_merge(["type" => "nested", "properties" => ["mimetype" => ["type" => "string", "index" => "not_analyzed"], "sha1" => ["type" => "string", "index" => "not_analyzed"], "filename" => ["type" => "string"], "filesize" => ["type" => "integer"]]], array_filter($current->getMappingOptions()))];
 }
Example #11
0
 /**
  *
  * {@inheritdoc}
  *
  */
 public function getChoiceList(FieldType $fieldType, array $choices)
 {
     /**@var ObjectPickerType $objectPickerType*/
     $objectPickerType = $this->registry->getType(ObjectPickerType::class)->getInnerType();
     /**@var ObjectChoiceLoader $loader */
     $loader = $objectPickerType->getChoiceListFactory()->createLoader($fieldType->getDisplayOptions()['type'], true);
     $all = $loader->loadAll();
     if (count($choices) > 0) {
         foreach ($all as $key => $data) {
             if (!in_array($key, $choices)) {
                 unset($all[$key]);
             }
         }
         // 			return $loader->loadChoiceList()->loadChoices($choices);
     }
     return $all;
 }
Example #12
0
 private function getMultipleField(FieldType $criteriaFieldType)
 {
     /**@var FieldType $criteria*/
     foreach ($criteriaFieldType->getChildren() as $criteria) {
         if (!$criteria->getDeleted()) {
             if ($criteria->getType() == ContainerFieldType::class) {
                 $out = $this->getMultipleField($criteria);
                 if ($out) {
                     return $out;
                 }
             } else {
                 if (isset($criteria->getDisplayOptions()['multiple']) && $criteria->getDisplayOptions()['multiple']) {
                     return $criteria->getName();
                 }
             }
         }
     }
     return false;
 }
 /**
  *
  * {@inheritdoc}
  *
  */
 public static function generateMapping(FieldType $current, $withPipeline)
 {
     return [$current->getName() => ["type" => "nested", "properties" => []]];
 }
Example #14
0
 /**
  *
  * {@inheritdoc}
  *
  */
 public static function generateMapping(FieldType $current, $withPipeline)
 {
     $out = [$current->getMappingOptions()['fromDateMachineName'] => ["type" => "date", "format" => 'date_time_no_millis'], $current->getMappingOptions()['toDateMachineName'] => ["type" => "date", "format" => 'date_time_no_millis']];
     if (!empty($current->getMappingOptions()['index'])) {
         $current->getMappingOptions()['fromDateMachineName']['index'] = $current->getMappingOptions()['index'];
         $current->getMappingOptions()['toDateMachineName']['index'] = $current->getMappingOptions()['index'];
     }
     if ($current->getMappingOptions()['nested']) {
         $out = [$current->getName() => ["type" => "nested", "properties" => $out]];
     }
     return $out;
 }