Пример #1
0
 /**
  * {@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);
     /** @var ClassMetadata */
     if (isset($metadata->associationMappings[$propertyName])) {
         $fieldDescription->setAssociationMapping($metadata->associationMappings[$propertyName]);
     }
     if (isset($metadata->fieldMappings[$propertyName])) {
         $fieldDescription->setFieldMapping($metadata->fieldMappings[$propertyName]);
     }
     return $fieldDescription;
 }