1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-22 16:29:55 +01:00

populators should ignore null value column formatters

This commit is contained in:
Christoph Schaefer 2012-06-14 22:04:55 +02:00
parent f6162c88c9
commit c513635dc7
2 changed files with 7 additions and 7 deletions
src/Faker/ORM

@ -91,7 +91,7 @@ class EntityPopulator
$class = $this->class->getName();
$obj = new $class;
foreach ($this->columnFormatters as $field => $format) {
if (null !== $field) {
if (null !== $format) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
$this->class->reflFields[$field]->setValue($obj, $value);
}

@ -20,7 +20,7 @@ class EntityPopulator
{
$this->class = $class;
}
public function getClass()
{
return $this->class;
@ -40,7 +40,7 @@ class EntityPopulator
{
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}
public function guessColumnFormatters(\Faker\Generator $generator)
{
$formatters = array();
@ -95,7 +95,7 @@ class EntityPopulator
}
return false;
}
public function setModifiers($modifiers)
{
$this->modifiers = $modifiers;
@ -140,7 +140,7 @@ class EntityPopulator
}
return $modifiers;
}
/**
* Insert one new record using the Entity class.
*/
@ -148,7 +148,7 @@ class EntityPopulator
{
$obj = new $this->class();
foreach ($this->getColumnFormatters() as $column => $format) {
if (null !== $column) {
if (null !== $format) {
$obj->setByName($column, is_callable($format) ? $format($insertedEntities, $obj) : $format);
}
}
@ -156,7 +156,7 @@ class EntityPopulator
$modifier($obj, $insertedEntities);
}
$obj->save($con);
return $obj->getPrimaryKey();
}