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

If $manager is not in the constructor it will not be able to $this->manager->getClassMetadata...

This commit is contained in:
Alvaro Marcos 2013-02-18 19:58:05 +01:00
parent fe9c56fa5b
commit 8bfb9b33c1

View File

@ -31,6 +31,9 @@ class Populator
public function addEntity($entity, $number, $customColumnFormatters = array(), $customModifiers = array(), $generateId = false)
{
if (!$entity instanceof \Faker\ORM\Doctrine\EntityPopulator) {
if (null === $this->manager) {
throw new \InvalidArgumentException("No entity manager passed to Doctrine Populator.");
}
$entity = new \Faker\ORM\Doctrine\EntityPopulator($this->manager->getClassMetadata($entity));
}
$entity->setColumnFormatters($entity->guessColumnFormatters($this->generator));