setParent() public méthode

public setParent ( WellCommerce\Bundle\CategoryBundle\Entity\CategoryInterface $parent = null )
$parent WellCommerce\Bundle\CategoryBundle\Entity\CategoryInterface
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $shop = $this->getReference('shop');
     foreach (self::$samples as $hierarchy => $name) {
         $category = new Category();
         $category->setEnabled(true);
         $category->setHierarchy($hierarchy);
         $category->setParent(null);
         $category->setProducts(new ArrayCollection());
         $category->setChildren(new ArrayCollection());
         $category->setChildrenCount(0);
         $category->setProductsCount(0);
         $category->addShop($shop);
         $category->translate($this->container->getParameter('locale'))->setName($name);
         $category->translate($this->container->getParameter('locale'))->setSlug(Sluggable::makeSlug($name));
         $category->translate($this->container->getParameter('locale'))->setShortDescription('');
         $category->translate($this->container->getParameter('locale'))->setDescription('');
         $category->mergeNewTranslations();
         $manager->persist($category);
         $this->setReference('category_' . $name, $category);
     }
     $manager->flush();
 }
 /**
  * @return Category
  */
 public function create()
 {
     $category = new Category();
     $category->setChildren(new ArrayCollection());
     $category->setProducts(new ArrayCollection());
     $category->setEnabled(true);
     $category->setHierarchy(0);
     $category->setParent(null);
     $category->setShops(new ArrayCollection());
     return $category;
 }
 public function create() : CategoryInterface
 {
     $category = new Category();
     $category->setEnabled(true);
     $category->setHierarchy(0);
     $category->setParent(null);
     $category->setShops($this->createEmptyCollection());
     $category->setChildren($this->createEmptyCollection());
     $category->setProducts($this->createEmptyCollection());
     $category->setProductsCount(0);
     $category->setChildrenCount(0);
     return $category;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $shop = $this->getReference('shop');
     foreach (self::$samples as $hierarchy => $name) {
         $category = new Category();
         $category->setEnabled(true);
         $category->setHierarchy($hierarchy);
         $category->setParent(null);
         $category->addShop($shop);
         $category->translate('en')->setName($name);
         $category->translate('en')->setSlug(Sluggable::makeSlug($name));
         $category->mergeNewTranslations();
         $manager->persist($category);
         $this->setReference('category_' . $name, $category);
     }
     $manager->flush();
 }
Exemple #5
0
 /**
  * Adds new child to category
  *
  * @param Category $child
  */
 public function addChild(Category $child)
 {
     $this->children[] = $child;
     $child->setParent($this);
 }