/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { for ($i = 0; $i < 2; $i++) { $category = new Category(); $category->setName('Catégorie ' . $i); $category->setSlug($category->getName()); $category->setContent($this->categoryContent[$i]); $category->setPictureName('default-image-' . $i . '.jpg'); $manager->persist($category); // Reference added once if ($i == 0) { $this->addReference('category', $category); } } $manager->flush(); }