Skip to content

Commit

Permalink
Merge pull request fzaninotto#70 from beberlei/BugfixDoctrineClassIns…
Browse files Browse the repository at this point in the history
…tantiation

Bugfix: Use ClassMetadata#newInstance()
  • Loading branch information
fzaninotto committed Nov 7, 2012
2 parents 8e13625 + 9010313 commit ca50787
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Faker/ORM/Doctrine/EntityPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ public function guessColumnFormatters(\Faker\Generator $generator)
*/
public function execute($manager, $insertedEntities)
{
$class = $this->class->getName();
$obj = new $class;
$obj = $this->class->newInstance();

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

$manager->persist($obj);

return $obj;
Expand Down

0 comments on commit ca50787

Please sign in to comment.