Added support for field options to FieldBuilder
This commit is contained in:
parent
95ad926c95
commit
25342b706d
@ -153,6 +153,35 @@ class FieldBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an option.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $value
|
||||||
|
*
|
||||||
|
* @return FieldBuilder
|
||||||
|
*/
|
||||||
|
public function option($name, $value)
|
||||||
|
{
|
||||||
|
if (!array_key_exists('options', $this->mapping)) {
|
||||||
|
$this->mapping['options'] = array();
|
||||||
|
}
|
||||||
|
$this->mapping['options'][$name] = $value;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets unsigned option.
|
||||||
|
*
|
||||||
|
* @param bool $flag
|
||||||
|
*
|
||||||
|
* @return FieldBuilder
|
||||||
|
*/
|
||||||
|
public function unsigned($flag = true)
|
||||||
|
{
|
||||||
|
return $this->option('unsigned', (bool)$flag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $strategy
|
* @param string $strategy
|
||||||
*
|
*
|
||||||
|
@ -174,6 +174,13 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals(array('columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'), $this->cm->fieldMappings['id']);
|
$this->assertEquals(array('columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'), $this->cm->fieldMappings['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateUnsignedOptionField()
|
||||||
|
{
|
||||||
|
$this->builder->createField('state', 'integer')->unsigned()->build();
|
||||||
|
|
||||||
|
$this->assertEquals(array('fieldName' => 'state', 'type' => 'integer', 'options' => array('unsigned' => true), 'columnName' => 'state'), $this->cm->fieldMappings['state']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddLifecycleEvent()
|
public function testAddLifecycleEvent()
|
||||||
{
|
{
|
||||||
$this->builder->addLifecycleEvent('getStatus', 'postLoad');
|
$this->builder->addLifecycleEvent('getStatus', 'postLoad');
|
||||||
|
Loading…
Reference in New Issue
Block a user