/** * Returns a new FieldDescription * * @abstract * @return \Sonata\AdminBundle\Admin\ORM\FieldDescription */ public function getNewFieldDescriptionInstance($class, $name, array $options = array()) { $metadata = $this->getMetadata($class); $fieldDescription = new FieldDescription(); $fieldDescription->setName($name); $fieldDescription->setOptions($options); if (isset($metadata->associationMappings[$name])) { $fieldDescription->setAssociationMapping($metadata->associationMappings[$name]); } if (isset($metadata->fieldMappings[$name])) { $fieldDescription->setFieldMapping($metadata->fieldMappings[$name]); } return $fieldDescription; }
/** * Returns a new FieldDescription * * @throws \RunTimeException * @param $class * @param $name * @param array $options * @return \Sonata\AdminBundle\Admin\ORM\FieldDescription */ public function getNewFieldDescriptionInstance($class, $name, array $options = array()) { if (!is_string($name)) { throw new \RunTimeException('The name argument must be a string'); } $metadata = $this->getMetadata($class); $fieldDescription = new FieldDescription(); $fieldDescription->setName($name); $fieldDescription->setOptions($options); if (isset($metadata->associationMappings[$name])) { $fieldDescription->setAssociationMapping($metadata->associationMappings[$name]); } if (isset($metadata->fieldMappings[$name])) { $fieldDescription->setFieldMapping($metadata->fieldMappings[$name]); } return $fieldDescription; }
public function testCamelize() { $this->assertEquals('FooBar', FieldDescription::camelize('foo_bar')); $this->assertEquals('FooBar', FieldDescription::camelize('foo bar')); $this->assertEquals('FOoBar', FieldDescription::camelize('fOo bar')); }