Add the category to allowed roots.

@param int $categoryId
173878
public function addCategoryToAllowedRoots($categoryId)
    {
        if (null === ($roots = $this->getUserAllowedRoots())) {
            return;
        }

        $categoryId = (int) $categoryId;
        $user = $this->getUser();

        /** @var StringUtil $stringUtil */
        $stringUtil = $this->framework->getAdapter(StringUtil::class);

        // Add the permissions on group level
        if ('custom' !== $user->inherit) {
            $groups = $this->db->fetchAll('SELECT id, newscategories, newscategories_roots FROM tl_user_group WHERE id IN('.\implode(',', \array_map('intval', $user->groups)).')');

            foreach ($groups as $group) {
                $permissions = $stringUtil->deserialize($group['newscategories'], true);

                if (\in_array('manage', $permissions, true)) {
                    $categoryIds = $stringUtil->deserialize($group['newscategories_roots'], true);
                    $categoryIds[] = $categoryId;

                    $this->db->update('tl_user_group', ['newscategories_roots' => \serialize($categoryIds)], ['id' => $group['id']]);
                }
            }
        }

        // Add the permissions on user level
        if ('group' !== $user->inherit) {
            $userData = $this->db->fetchAssoc('SELECT newscategories, newscategories_roots FROM tl_user WHERE id=?', [$user->id]);
            $permissions = $stringUtil->deserialize($userData['newscategories'], true);

            if (\in_array('manage', $permissions, true)) {
                $categoryIds = $stringUtil->deserialize($userData['newscategories_roots'], true);
                $categoryIds[] = $categoryId;

                $this->db->update('tl_user', ['newscategories_roots' => \serialize($categoryIds)], ['id' => $user->id]);
            }
        }

        // Add the new element to the user object
        $user->newscategories_roots = \array_merge($roots, [$categoryId]);
    }
1084590
public static function findByCategoryId( $categoryId ) {

		$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );

		return self::find()->where( "$optionTable.categoryId=:id", [ ':id' => $categoryId ] )->all();
	}
745911
public function getCategoryTree($categoryId = null)
    {
        $method = 'category_tree';

        if ($categoryId !== null) {
            $method .= '/'.$categoryId;
        }

        return $this->call($method);
    }
337174
public function rebuildStoreIndex($storeId, $categoryIds = null)
    {
        $lastCategoryId = 0;

        do {
            $categories = $this->getSearchableCategories($storeId, $categoryIds, $lastCategoryId);

            foreach ($categories as $categoryData) {
                $lastCategoryId = (int) $categoryData['entity_id'];
                yield $lastCategoryId => $categoryData;
            }
        } while (!empty($categories));
    }
389852
public function putAction($categoryId, $keywordId, Request $request)
    {
        $keyword = $this->getKeywordRepository()->findById($keywordId);

        if (!$keyword) {
            return $this->handleView($this->view(null, 404));
        }

        $force = $request->get('force');
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $keyword->setKeyword($request->get('keyword'));

        $keyword = $this->getKeywordManager()->save($keyword, $category, $force);

        $this->getEntityManager()->persist($keyword);
        $this->getEntityManager()->flush();

        return $this->handleView($this->view($keyword));
    }
478665
public function seedCategory($category_id = 0)
    {
        $categories = $this->blender->getCategoryMap();
        if (isset($categories['ids'][$category_id]) && isset($categories['ids'][$category_id]['lineage'])) {
            return $categories['ids'][$category_id]['lineage'];
        }

        return '';
    }
650599
public function addSubCategory(CategoryInterface $category)
    {
        if (!$this
            ->subCategories
            ->contains($category)
        ) {
            $this
                ->subCategories
                ->add($category);
        }

        return $this;
    }
905807
public function getCategoryById($categoryId)
    {
        //wyszukanie w płaskiej liście
        return isset($this->_flatCategories[$categoryId]) ? $this->_flatCategories[$categoryId] : null;
    }
717733
def add_category(self, category):
        
        self._categories = self._ensure_append(category, self._categories)
1126315
protected function deleteLinked($category_id)
    {
        $this->db->delete('category_translation', array('category_id' => $category_id));
        $this->db->delete('file', array('entity' => 'category', 'entity_id' => $category_id));
        $this->db->delete('alias', array('entity' => 'category', 'entity_id' => $category_id));
    }
176182
public function addCategory(CategoryInterface $category)
    {
        if (!$this
            ->categories
            ->contains($category)
        ) {
            $this
                ->categories
                ->add($category);
        }

        return $this;
    }
1365534
public function archive($objectID, $categoryConst, $entryID) {
        $this->api->request(
            'cmdb.category.archive',
            [
                'object' => $objectID,
                'category' => $categoryConst,
                'entry' => $entryID
            ]
        );

        return $this;
    }
903189
public function addCategory(\Hexmedia\ContentBundle\Entity\Category $category)
    {
        $this->categories[] = $category;

        return $this;
    }
707858
public function deleteAction($categoryId, $keywordId)
    {
        $keyword = $this->getKeywordRepository()->findById($keywordId);
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $this->getKeywordManager()->delete($keyword, $category);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
323093
public function getCategory($categoryId)
    {

        // try to load the category with the passed ID
        foreach ($this->categories as $category) {
            if ($category[MemberNames::ENTITY_ID] == $categoryId) {
                return $category;
            }
        }

        // throw an exception if the category is NOT available
        throw new \Exception(sprintf('Can\'t load category with ID %d in file %s on line %d', $categoryId));
    }
508627
public function getCategory4Id($categoryId)
    {
        /** @var \ZfcTicketSystem\Entity\Repository\TicketCategory $repository */
        $repository = $this->getEntityManager()->getRepository($this->getEntityOptions()->getTicketCategory());
        return $repository->getCategory4Id($categoryId);
    }
1299862
public function saveMediaCategoryAssignments(int $mediaId, array $categoryIds = null)
    {
        // Delete current category assignments for this media ID
        $this->deleteMediaCategoryAssignments($mediaId);

        // Insert all assignments, if the category ID's array is not empty
        if (null !== $categoryIds) {
            $this->sql = 'insert into media_category_map (media_id, category_id) values ';
            foreach ($categoryIds as $id) {
                $this->sql .= '(?, ?),';
                $this->bindValues[] = $mediaId;
                $this->bindValues[] = $id;
            }
            $this->sql = rtrim($this->sql, ',') . ';';
            $this->execute();
        }
    }