/**
  * {@inheritdoc}
  */
 public function mapValue($fieldName, $value, MetaInformationInterface $metaInformation)
 {
     if (is_array($value)) {
         return false;
     }
     if ($metaInformation->getField($fieldName) && $metaInformation->getField($fieldName)->getter) {
         return false;
     }
     $fieldSuffix = $this->removePrefixedKeyFieldName($fieldName);
     if ($fieldSuffix === false) {
         return false;
     }
     if (array_key_exists($fieldSuffix, Field::getComplexFieldMapping())) {
         return false;
     }
     return true;
 }
 /**
  * @param Field $field
  *
  * @return array
  */
 private function mapCollection(Field $field)
 {
     /** @var Collection $value */
     $value = $field->getValue();
     $getter = $field->getGetterName();
     if (!empty($getter)) {
         $values = array();
         foreach ($value as $relatedObj) {
             $values[] = $relatedObj->{$getter}();
         }
         return $values;
     }
     $collection = array();
     foreach ($value as $object) {
         $metaInformation = $this->metaInformationFactory->loadInformation($object);
         $field = array();
         $document = $this->createDocument($metaInformation);
         foreach ($document as $fieldName => $value) {
             $field[$fieldName] = $value;
         }
         $collection[] = $field;
     }
     return $collection;
 }
Exemple #3
0
 public function testGetNameWithAlias_Integer()
 {
     $field = new Field(array('name' => 'test', 'type' => 'integer'));
     $this->assertEquals('test_i', $field->getNameWithAlias());
 }
Exemple #4
0
 public function testCostomFieldType()
 {
     $field = new Field(array('name' => 'costumtype', 'type' => 'my_special_type'));
     $this->assertEquals('costumtype', $field->getNameWithAlias());
 }