コード例 #1
0
ファイル: ModelManager.php プロジェクト: LamaDelRay/test_symf
 /**
  * {@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;
 }
コード例 #2
0
 public function testGetTargetEntity()
 {
     $assocationMapping = array('type' => 'integer', 'fieldName' => 'position', 'targetEntity' => 'someValue');
     $field = new FieldDescription();
     $this->assertNull($field->getTargetEntity());
     $field->setAssociationMapping($assocationMapping);
     $this->assertEquals('someValue', $field->getTargetEntity());
 }