public function load(ObjectManager $manager) { // Liste des noms de catégorie à ajouter $names = array('Famille', 'Administration', 'Entretien maison', 'Eau/Electricite/Gaz', 'Transports', 'Sports', 'Lieux', 'Pour manger', 'Achats', 'Foulon', 'Livre d\'or'); foreach ($names as $name) { // On crée la catégorie $category = new Category(); $category->setName($name); // On la persiste $manager->persist($category); } // On déclenche l\'enregistrement de toutes les catégories $manager->flush(); }
/** * {@inheritDoc} */ public function setName($name) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', [$name]); return parent::setName($name); }