kmaci
kmaci

Reputation: 3284

Function in DataFixture class always return null but works in Controller

My function findByDimensions() works correctly in Controller but if I use it in the DataFixture class, it always returns null.

Code in controller:

$manager = $this->getDoctrine()->getEntityManager();
$smRepository = $manager->getRepository('Something\Repository');
$smRepository->findByDimensions(1, 2);

I got the correct object here. But if I use it in DataFixture class, I always get null:

public function load(ObjectManager $manager) {
....
$smRepository = $manager->getRepository('Something\Repository');
$smRepository->findByDimensions(1, 2);
....
}

Where should be the mistake? The first manager is of the class EntityManager, the second is ObjectManager from DataFixture class.

Upvotes: 0

Views: 279

Answers (1)

Łukasz
Łukasz

Reputation: 643

When you're loading fixtures your database is empty.

This is cause by purging on doctrine:fixtures:load You can check this out:

doctrine:fixtures:load --append

Upvotes: 3

Related Questions