/** * {@inheritdoc} */ public function getNewFieldDescriptionInstance($class, $name, array $options = array()) { if (!is_string($name)) { throw new \RunTimeException('The name argument must be a string'); } if (!isset($options['route']['name'])) { $options['route']['name'] = 'edit'; } if (!isset($options['route']['parameters'])) { $options['route']['parameters'] = array(); } list($metadata, $propertyName, $parentAssociationMappings) = $this->getParentMetadataForProperty($class, $name); $fieldDescription = new FieldDescription(); $fieldDescription->setName($name); $fieldDescription->setOptions($options); $fieldDescription->setParentAssociationMappings($parentAssociationMappings); if (isset($metadata->associationMappings[$propertyName])) { $fieldDescription->setAssociationMapping($metadata->associationMappings[$propertyName]); } if (isset($metadata->fieldMappings[$propertyName])) { $fieldDescription->setFieldMapping($metadata->fieldMappings[$propertyName]); } return $fieldDescription; }
public function testGetFieldMapping() { $fieldMapping = array('type' => 'integer', 'fieldName' => 'position', 'id' => 'someId'); $field = new FieldDescription(); $field->setFieldMapping($fieldMapping); $this->assertEquals($fieldMapping, $field->getFieldMapping()); }