public function load(ObjectManager $manager)
 {
     foreach (range(1, 100) as $i) {
         $category = new Category();
         $category->setName('Parent Category #' . $i);
         $this->addReference('parent-category-' . $i, $category);
         $manager->persist($category);
     }
     $manager->flush();
     foreach (range(1, 100) as $i) {
         $category = new Category();
         $category->setName('Category #' . $i);
         $category->setParent($this->getReference('parent-category-' . $i));
         $this->addReference('category-' . $i, $category);
         $manager->persist($category);
     }
     $manager->flush();
 }
Exemplo n.º 2
0
 /**
  * Remove a category in the product association.
  * (Owning side).
  *
  * @param Category $category The category to disassociate
  */
 public function removeCategory($category)
 {
     $category->removeProduct($this);
     $this->categories->removeElement($category);
 }