1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-23 16:59:53 +01:00

Bugfix: EntityPopulator did not correctly fetch an entity from the list of associations for ManyToOne or OneToOne

This commit is contained in:
Benjamin Eberlei 2012-11-07 13:29:17 +01:00
parent ce23e17807
commit 0befd59974

View File

@ -73,9 +73,10 @@ class EntityPopulator
}
foreach ($this->class->getAssociationNames() AS $assocName) {
if (!$this->class->isIdentifier($assocName) || !$this->class->isCollectionValuedAssociation($assocName)) {
if ($this->class->isCollectionValuedAssociation($assocName)) {
continue;
}
$relatedClass = $this->class->getAssociationTargetClass($assocName);
$formatters[$assocName] = function($inserted) use($relatedClass) { return isset($inserted[$relatedClass]) ? $inserted[$relatedClass][mt_rand(0, count($inserted[$relatedClass]) - 1)] : null; };
}
@ -101,4 +102,4 @@ class EntityPopulator
return $obj;
}
}
}