Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Oct 29, 2011
1 parent 1a67776 commit 5ae33a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Faker/ORM/Doctrine/EntityPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ public function guessColumnFormatters(\Faker\Generator $generator)
/**
* Insert one new record using the Entity class.
*/
public function execute($con, $insertedEntities)
public function execute($manager, $insertedEntities)
{
$obj = new $this->class->getName();
$class = $this->class->getName();
$obj = new $class;
foreach ($this->columnFormatters as $field => $format) {
if (null !== $field) {
$value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
$this->class->reflFields[$field]->setValue($obj, $value);
}
}
$con->persist($obj);
$manager->persist($obj);

return $obj;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Faker/ORM/Doctrine/Populator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ public function addEntity($entity, $number, $customColumnFormatters = array())
*/
public function execute($entityManager = null)
{
if (null !== $entityManager) {
if (null === $entityManager) {
$entityManager = $this->manager;
}
if (null === $entityManager) {
throw new \InvalidArgumentException("No entity manager passed to Doctrine Populator.");
}

$insertedEntities = array();
foreach ($this->quantities as $class => $number) {
Expand Down

0 comments on commit 5ae33a2

Please sign in to comment.