Usuwa kategorię z obiektu i id
@param integer $categoryId id kategorii
333395
public function deleteCategoryRelation($categoryId)
    {
        //brak kategorii - nic do zrobienia
        if (null === $categoryRecord = (new CmsCategoryQuery)
            ->findPk($categoryId)) {
            return;
        }
        //wyszukiwanie relacji
        if (null === $relationRecord = (new CmsCategoryRelationQuery)
            ->whereCmsCategoryId()->equals($categoryRecord->id)
            ->andFieldObject()->equals($this->_object)
            ->andFieldObjectId()->equals($this->_objectId)
            ->findFirst()) {
            //brak relacji - nic do zrobienia
            return;
        }
        //usunięcie relacji
        $relationRecord->delete();
    }
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));
    }
315349
protected function setCategoryGroup($category_group_id)
    {
        $this->data_category_group = array();

        if (is_numeric($category_group_id)) {

            $conditions = array(
                'language' => 'und',
                'category_group_id' => $category_group_id
            );

            $this->data_category_group = $this->category_group->get($conditions);

            if (empty($this->data_category_group)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareCategoryGroup($this->data_category_group);
        }
    }
293096
public function getCategoryTree($parentCategoryId = null)
    {
        //brak zdefiniowanej kategorii
        if ($parentCategoryId === null) {
            return $this->_categoryTree;
        }
        //wyszukiwanie kategorii
        return $this->_searchChildren($this->_categoryTree, $parentCategoryId);
    }
731989
public function findTranslated($category, $languageId)
    {
        return CategoryTranslation::whereCategoryId($category->id)
            ->whereLanguageId($languageId)
            ->first();
    }
1006278
public function loadAttributesData(int $categoryId)
    {
        $binds = [':category_id' => $categoryId];

        $select = $this->getConnection()->select();
        $select->from($this->getMainTable())->where(sprintf("%s = :category_id", $this->getIdFieldName()));

        return $this->getConnection()->fetchAll($select, $binds);
    }
280046
public function editCategoryGroup($category_group_id = null)
    {
        $this->setCategoryGroup($category_group_id);
        $this->setTitleEditCategoryGroup();
        $this->setBreadcrumbEditCategoryGroup();

        $this->setData('category_group', $this->data_category_group);
        $this->setData('can_delete', $this->canDeleteCategoryGroup());
        $this->setData('languages', $this->language->getList(array('enabled' => true)));
        $this->setData('category_group_types', $this->category_group->getTypes());

        $this->submitEditCategoryGroup();
        $this->outputEditCategoryGroup();
    }
1206641
public function cdeleteAction($categoryId, Request $request)
    {
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);

        $ids = array_filter(explode(',', $request->get('ids')));
        foreach ($ids as $id) {
            $keyword = $this->getKeywordRepository()->findById($id);
            $this->getKeywordManager()->delete($keyword, $category);
        }

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

        return $this->handleView($this->view());
    }
351490
protected function updateCategory($category_id)
    {
        if (!$this->isError() && !$this->category->update($category_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
912064
public static function get_category_children_visibility($categoryid) {
        global $DB;
        $category = \core_course_category::get($categoryid);
        $select = $DB->sql_like('path', ':path');
        $path = $category->path . '/%';

        $sql = "SELECT c.id, c.visible
                  FROM {course_categories} c
                 WHERE ".$select;
        $params = array('path' => $path);
        return $DB->get_records_sql($sql, $params);
    }
482071
public function getChildrenCount($categoryId)
    {
        $select = $this->getConnection()->select()->from(
            $this->getEntityTable(),
            'children_count'
        )->where(
            'entity_id = :entity_id'
        );
        $bind = ['entity_id' => $categoryId];

        return $this->getConnection()->fetchOne($select, $bind);
    }
1100361
private function loadCategoryNames($categoryIds, $storeId)
    {
        $loadCategoryIds = $categoryIds;

        if (isset($this->categoryNameCache[$storeId])) {
            $loadCategoryIds = array_diff($categoryIds, array_keys($this->categoryNameCache[$storeId]));
        }

        $loadCategoryIds  = array_map('intval', $loadCategoryIds);
        $useNameAttribute = $this->getUseNameInSearchAttribute();

        if (!empty($loadCategoryIds) && $useNameAttribute && $useNameAttribute->getId()) {
            $select = $this->prepareCategoryNameSelect($loadCategoryIds, $storeId);
            $entityIdField = $this->getEntityMetaData(CategoryInterface::class)->getIdentifierField();

            foreach ($this->getConnection()->fetchAll($select) as $row) {
                $categoryId = (int) $row[$entityIdField];
                $this->categoryNameCache[$storeId][$categoryId] = '';
                if ((bool) $row['use_name']) {
                    $this->categoryNameCache[$storeId][$categoryId] = $row['name'];
                }
            }
        }

        return isset($this->categoryNameCache[$storeId]) ? $this->categoryNameCache[$storeId] : [];
    }
310389
protected function setCategory($category_id)
    {
        $this->data_category = array();

        if (is_numeric($category_id)) {

            //Set unexisting language code to get original titles.
            //Otherwise it will be translated to the current language
            $conditions = array(
                'language' => 'und',
                'category_id' => $category_id
            );

            $this->data_category = $this->category->get($conditions);

            if (empty($this->data_category)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareCategory($this->data_category);
        }
    }
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));
    }
146295
public function findMediaByCategoryId(int $catId = null)
    {
        if (null === $catId) {
            return;
        }

        $this->sql = <<<SQL
select
    mc.category,
    m.id,
    m.file,
    m.caption
from media_category mc
join media_category_map mcp on mc.id = mcp.category_id
join media m on mcp.media_id = m.id
where mc.id = ?
SQL;
        $this->bindValues[] = $catId;
        return $this->find();
    }
77624
private function handleCategory($categoryId)
    {
        $categoryData = $this->getCategory($categoryId);

        if ($categoryData instanceof CategoryModel) {
            return $categoryData->getPath();
        }

        return '';
    }
610660
public function handleRemove(int $id) : void
    {
        if ($this->presenter->isAjax() && $this->presenter->user->isAllowed(CategoryAuthorizator::RES_REMOVE))
        {
            $this->categoryEntity = $this->categoryRepository->findOneById($id);

            $this->categoryManager->delete($this->categoryEntity);

            $this->presenter->notificationAjax(
                'Kategorie odstaněna',
                "Kategorie '{$this->categoryEntity->getName()}' byla úspěšně odstaněna.",
                'success',
                FALSE
            );

            $this->presenter->handleModalToggle('hide', '#wakers_category_remove_modal', FALSE);

            $this->onRemove();
        }
    }