public function load(ObjectManager $manager) { // Liste des noms de catégorie à ajouter $names = array('Jeux vidéos', 'Projets', 'Ecoles', 'Divers'); foreach ($names as $name) { $category = new Category(); $category->setName($name); $manager->persist($category); } $manager->flush(); }
public function load(ObjectManager $em) { $no_category = new Category(); $no_category->setName('No category'); $no_category->setDescription('Desktops No category'); $no_category->setImage('no-category.jpg'); $no_category->setIsActive(1); $blog = new Category(); $blog->setName('Blog'); $blog->setDescription('Blog Description'); $blog->setImage('blog.jpg'); $blog->setIsActive(1); $shop = new Category(); $shop->setName('Shop'); $shop->setDescription('Shop Description'); $shop->setImage('shop.jpg'); $shop->setIsActive(1); $em->persist($no_category); $em->persist($blog); $em->persist($shop); $em->flush(); $this->addReference('category-no_category', $no_category); $this->addReference('category-blog', $blog); $this->addReference('category-shop', $shop); }
public function load(ObjectManager $em) { $forum = new Category(); $forum->setName('Forum tutorial'); $forum->setDescription('Forum Description'); $forum->setImage('forum.jpg'); $forum->setIsActive(1); $blog = new Category(); $blog->setName('Blog tutorial'); $blog->setDescription('Blog Description'); $blog->setImage('blog.jpg'); $blog->setIsActive(1); $shop = new Category(); $shop->setName('Shop tutorial'); $shop->setDescription('Shop Description'); $shop->setImage('shop.jpg'); $shop->setIsActive(1); $em->persist($forum); $em->persist($blog); $em->persist($shop); $em->flush(); $this->addReference('category-forum', $forum); $this->addReference('category-blog', $blog); $this->addReference('category-shop', $shop); }
/** * Creates a form to delete a Category entity. * * @param Category $category The Category entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Category $category) { return $this->createFormBuilder()->setAction($this->generateUrl('admin_category_delete', array('id' => $category->getId())))->setMethod('DELETE')->getForm(); }