Webonaute / DoctrineFixturesGeneratorBundle

Generate Fixture from your existing data in your database. You can specify the Entity name and the IDs you want to import in your fixture.
63 stars 47 forks source link

Method addRefernece should be a very first after object constructor #36

Closed piela closed 7 years ago

piela commented 7 years ago

Hi, I found problem in generated files, if object reffered to itself (it is possible in tree structures), fixture throws Error.

Sample:

$item241 = new MenuItem(); $item241->setName("main"); $item241->setRoute("home"); $item241->setRouteParameters(unserialize('a:0:{}')); $item241->setLft(1); $item241->setLvl(0); $item241->setRgt(40); $item241->setRoot($this->getReference('_reference_TMSolutionMenuBundleEntityMenuItem241')); $this->addReference('_reference_TMSolutionMenuBundleEntityMenuItem241', $item241); $item241->setPosition(1);

Should be:

$item241 = new MenuItem(); $this->addReference('_reference_TMSolutionMenuBundleEntityMenuItem241', $item241); $item241->setName("main"); $item241->setRoute("home"); $item241->setRouteParameters(unserialize('a:0:{}')); $item241->setLft(1); $item241->setLvl(0); $item241->setRgt(40); $item241->setRoot($this->getReference('_reference_TMSolutionMenuBundleEntityMenuItem241')); $item241->setPosition(1);

Thx for good tool!

Webonaute commented 7 years ago

can you please tell me if this fix the issue?