1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-20 23:39:51 +01:00

Some fixes

This commit is contained in:
Benjamin Eberlei 2011-10-29 23:08:13 +02:00
parent 1a67776e1d
commit 5ae33a24ba
2 changed files with 8 additions and 4 deletions

View File

@ -86,16 +86,17 @@ class EntityPopulator
/**
* 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;
}

View File

@ -50,9 +50,12 @@ class Populator
*/
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) {