Adds a new category

@param string $name
@param int $parent
@param ShopInterface $shop

@return CategoryInterface
486897
public function quickAddCategory(string $name, int $parent, ShopInterface $shop) : CategoryInterface
    {
        $parentCategory = $this->getRepository()->find($parent);

        /** @var CategoryInterface $category */
        $category = $this->initResource();
        $category->setParent($parentCategory);
        $category->addShop($shop);

        foreach ($this->getLocales() as $locale) {
            $this->translateCategory($locale, $category, $name);
        }
        $em = $this->getDoctrineHelper()->getEntityManager();
        $em->persist($category);
        $em->flush();

        return $category;
    }
859991
public function addCategory(\HarvestCloud\CoreBundle\Entity\Category $child)
    {
        $this->children[] = $child;

        $child->setParent($this);
    }
1144762
protected function generateWildcard(
        string $wildcard,
        ?NodeInterface $parent,
        ?string $name
    ): NodeInterface{
        $node   = new WildcardNode($this, $parent, $name);

        $node->setWildcard($wildcard);

        return $node;
    }
889392
public function addChild(MenuItemInterface $child)
    {
        $child->setParent($this);
        $this->children[] = $child;

        return $this;
    }
176182
public function addCategory(CategoryInterface $category)
    {
        if (!$this
            ->categories
            ->contains($category)
        ) {
            $this
                ->categories
                ->add($category);
        }

        return $this;
    }
941967
public function addPage(Page $page): Category
    {
        $this->children->add($page);

        if ($page->getCategory() !== $this) {
            $page->setCategory($this);
        }

        return $this;
    }
800657
public function addCategory($code, $name)
    {
        if (empty($code) || empty($name)) {
            return $this;
        }
        
        $data = (array) $this->getCategories();
        $data[] = [
            'code' => $code,
            'name' => $name,
        ];
        
        $this->setData('categories', $data);
        
        return $this;
    }
269394
public function addChild(CategoryInterface $child)
    {
        $child->setParent($this);
        $this->children[] = $child;

        return $this;
    }
198237
public function addChild($name, $value = null, $namespace = null)
    {
        return parent::addChild($name, ($value !== null ? str_replace('&', '&amp;', $value) : null), $namespace);
    }
645177
public function setParent(\Octopouce\AdminBundle\Entity\Category $parent = null)
    {
        $this->parent = $parent;

        return $this;
    }
231730
public function addChild($name, $value = NULL, $namespace = NULL) {
		return parent::addChild($name, ($value !== NULL ? str_replace('&', '&amp;', $value) : NULL), $namespace);
	}
630907
protected function addChild(string $id, string $parent): ?Fluent
    {
        $node = $this->descendants($this->items, $parent);

        // it might be possible parent is not defined due to ACL, in this
        // case we should simply ignore this request as child should
        // inherit parent ACL access.
        if (! isset($node)) {
            return null;
        }

        $item = $node->get('childs');
        $item[$id] = $this->toFluent($id);

        $node->childs($item);

        return $item[$id];
    }
573736
public function createElement(Node $parent, $name)
    {
        switch ($name) {
            case 'app:collection':
                return new Collection($parent);
            case 'app:workspace':
                return new Workspace($parent);
        }

        return null;
    }
1139903
public function get(string $name, string $moduleId, int $shopId): ShopModuleSetting
    {
        /**
         * The same entity was splitted between two tables.
         * Till we can't refactor tables we have to get data from both.
         */
        $settingsData = array_merge(
            $this->getDataFromOxConfigTable($name, $moduleId, $shopId),
            $this->getDataFromOxConfigDisplayTable($name, $moduleId)
        );

        $setting = new ShopModuleSetting();
        $setting
            ->setName($name)
            ->setValue($this->shopSettingEncoder->decode($settingsData['type'], $settingsData['value']))
            ->setShopId($shopId)
            ->setModuleId($moduleId)
            ->setType($settingsData['type']);

        if (isset($settingsData['oxvarconstraint'])
            && is_string($settingsData['oxvarconstraint'])
            && $settingsData['oxvarconstraint'] !== ''
        ) {
            $setting->setConstraints(
                explode('|', $settingsData['oxvarconstraint'])
            );
        }

        if (isset($settingsData['oxgrouping'])) {
            $setting->setGroupName($settingsData['oxgrouping']);
        }

        if (isset($settingsData['oxpos'])) {
            $setting->setPositionInGroup(
                (int) $settingsData['oxpos']
            );
        }

        return $setting;
    }
1109613
protected void addChildren(CmsTreeItem parent, List<CmsGalleryTreeEntry> children, List<String> selectedGalleries) {

        if (children != null) {
            for (CmsGalleryTreeEntry child : children) {
                // set the category tree item and add to parent tree item
                CmsTreeItem treeItem = createTreeItem(child, selectedGalleries, true);
                if ((selectedGalleries != null) && selectedGalleries.contains(child.getPath())) {
                    parent.setOpen(true);
                    openParents(parent);
                }
                parent.addChild(treeItem);
                addChildren(treeItem, child.getChildren(), selectedGalleries);
            }
        }
    }
1304691
public function add(IEntity $parent, array $add)
	{
		if (!$add) {
			return;
		}

		$this->mapperCoordinator->beginTransaction();
		$list = $this->buildList($parent, $add);
		$this->connection->query('INSERT INTO %table %values[]', $this->joinTable, $list);
	}
97445
public function addNew($childName, $parentName, $parentKeyFields)
    {
        // if there is no parent set yet, cant show a button that wont work.
        foreach ($parentKeyFields as $key => $val) {
            if (!trim($val)) {
                return '';
            }
        }

        $elements = array(
            'parent_name' => $parentName,
            'child_name'  => $childName,
        );

        $submitButton = array(
            'name' => 'submit',
            'type' => 'Zend\Form\Element\Submit',
            'attributes' => array(
                'value' => ' + ' . $this->labels[$childName],
            ),
        );

        $form = new \SpeckCatalog\Form\AddChild;
        $form->addElements($elements)
            ->addParent($parentKeyFields);
        $form->add($submitButton);

        $view = $this->getView();
        return $view->render($this->partialDir . 'add', array('addForm' => $form));
    }