[POST] [/category/<id>]
@return array    Category
336076
public function actionIndexPost($id=NULL)
	{
		if ($id === NULL)
		{
			$category = new Categories;
			$category->parent_id = 1;
		}
		else
		{
			$category = Categories::model()->findByPk($id);
			if ($category == NULL)
				throw new CHttpException(404, Yii::t('Api.category', 'A category with the id of {{id}} was not found.', array('{{id}}' => $id)));
		}

		$category->attributes = $_POST;

		if ($category->save())
			return $category->getAPIAttributes(array('parent_id'), array('parent', 'metadata'));

		return $this->returnError(400, NULL, $category->getErrors());
	}
299238
public function getAllPostsOfCategory($lang, $postType, $categoryID)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess($postType, 'read')) {
            return $this->noPermission();
        }
        // order info
        $orderBy = (isset($_GET['order'])) ? $_GET['order'] : 'postID';
        $orderType = (isset($_GET['type'])) ? $_GET['type'] : 'DESC';

        // get postIDs from relations
        $relations = DB::table(categoriesRelationTable($postType))->where('categoryID', $categoryID)->select('postID')->get();
        $postIDs = [];
        foreach ($relations as $postID){
            $postIDs[] = $postID->postID;
        }
        // get post list
        $list = DB::table($postType)->whereIn('postID', $postIDs)->orderBy($orderBy, $orderType)->paginate(Post::$rowsPerPage);
        return Language::filterRows($list);
    }
1245046
public static function posts()
    {
        if (!getConfig('sitemap.posts')) {
            return [];
        }

        $table = TableRegistry::get('MeCms.PostsCategories');
        $url = Cache::read('sitemap', $table->getCacheName());

        if (!$url) {
            $alias = $table->Posts->getAlias();
            $categories = $table->find('active')
                ->select(['id', 'lft', 'slug'])
                ->contain($alias, function (Query $q) use ($alias) {
                    return $q->find('active')
                        ->select(['category_id', 'slug', 'modified'])
                        ->order([sprintf('%s.modified', $alias) => 'DESC']);
                })
                ->order(['lft' => 'ASC']);

            if ($categories->isEmpty()) {
                return [];
            }

            $latest = $table->Posts->find('active')
                ->select(['modified'])
                ->order([sprintf('%s.modified', $alias) => 'DESC'])
                ->firstOrFail();

            //Adds posts index, categories index and posts search
            $url[] = self::parse(['_name' => 'posts'], ['lastmod' => $latest->modified]);
            $url[] = self::parse(['_name' => 'postsCategories']);
            $url[] = self::parse(['_name' => 'postsSearch'], ['priority' => '0.2']);

            foreach ($categories as $category) {
                //Adds the category
                $url[] = self::parse(
                    ['_name' => 'postsCategory', $category->slug],
                    ['lastmod' => array_value_first($category->posts)->modified]
                );

                //Adds each post
                foreach ($category->posts as $post) {
                    $url[] = self::parse(['_name' => 'post', $post->slug], ['lastmod' => $post->modified]);
                }
            }

            Cache::write('sitemap', $url, $table->getCacheName());
        }

        return $url;
    }
193473
public function getCategoryTitle()
    {
        $this->categoryTitle = $this->category ? $this->category->getTitle() : null;

        return $this->categoryTitle;
    }
816007
public function getCategory() : ?string 
    {
        if ( ! $this->hasCategory()) {
            $this->setCategory($this->getDefaultCategory());
        }
        return $this->category;
    }
220001
public function categories()
    {
        $resource = '/venues/categories';
        $response = $this->makeApiRequest($resource);

        if(property_exists($response, 'categories')) {
            return $response->categories;
        }

        return array();
    }
993418
public function get_categories_with_fields() : array {
        if ($this->categories === null) {
            $this->categories = api::get_categories_with_fields($this->get_component(), $this->get_area(), $this->get_itemid());
        }
        $handler = $this;
        array_walk($this->categories, function(category_controller $c) use ($handler) {
            $c->set_handler($handler);
        });
        return $this->categories;
    }
1335208
public function category()
    {
        $category = $this->getCurrentCategory();

        if ($category) {
            $this->blogPosts = $category->BlogPosts();

            if ($this->isRSS()) {
                return $this->rssFeed($this->blogPosts, $category->getLink());
            }
            return $this->render();
        }

        $this->httpError(404, 'Not Found');

        return null;
    }
441613
public function query() : array
    {
        $categories = Category::where('parent_id', null)->with('allChildrenTerm')->get();
        $allCategories = collect();

        foreach ($categories as $category) {
            $allCategories = $allCategories->merge($this->getCategory($category));
        }

        return [
            'category' => $allCategories,
        ];
    }
471880
public function getAll()
    {
        return array_merge(
            [
                'id'       => $this->getUrlParser()->getId(),
                'category' => $this->getUrlParser()->getCategory(),
            ],
            $this->getPictures(),
            $this->getProperties(),
            $this->getDescription()
        );
    }
612835
public function getTrailIds(NewsCategoryModel $category)
    {
        static $ids;

        if (!\is_array($ids)) {
            /** @var Database $db */
            $db = $this->framework->createInstance(Database::class);

            $ids = $db->getParentRecords($category->id, $category->getTable());
            $ids = \array_map('intval', \array_unique($ids));

            // Remove the current category
            unset($ids[\array_search($category->id, $ids, true)]);
        }

        return $ids;
    }
1343223
private function get_default_category_id() {
        global $CFG;

        if ($this->defaultcategoryid === null) {
            $category = core_course_category::get_default();
            $this->defaultcategoryid = $category->id;
        }

        return $this->defaultcategoryid;
    }
312836
protected function actionListCategory()
    {
        list($selected, $action, $value) = $this->getPostedAction();

        $updated = $deleted = 0;

        foreach ($selected as $category_id) {

            if ($action === 'status' && $this->access('category_edit')) {
                $updated += (int) $this->category->update($category_id, array('status' => $value));
            }

            if ($action === 'delete' && $this->access('category_delete')) {
                $deleted += (int) $this->category->delete($category_id);
            }
        }

        if ($updated > 0) {
            $message = $this->text('Updated %num item(s)', array('%num' => $updated));
            $this->setMessage($message, 'success');
        }

        if ($deleted > 0) {
            $message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
            $this->setMessage($message, 'success');
        }
    }
51573
public function get_parent_category() {
        if (!empty($this->parent)) {
            $parent_category = new grade_category(array('id' => $this->parent));
            return $parent_category;
        } else {
            return null;
        }
    }
1259878
protected function getSidebarPostId() {
		$post_id = intval( get_the_ID() );

		if ( $this->isBlog() ) {
			$post_id = intval( get_option( 'page_for_posts' ) );
		}

		$post_id = intval( apply_filters( 'app_sidebar_context_post_id', $post_id ) );

		return $post_id;
	}
462866
public function load_parent_category() {
        if (empty($this->parent_category->id)) {
            $this->parent_category = $this->get_parent_category();
        }
        return $this->parent_category;
    }
621140
public function getByCategoryID($iCategoryID)
    {
        if (empty($iCategoryID)) {
            return [];
        }

        //Get category data
        $this->addCategoryData($iCategoryID, true);
        $this->arResult = array_reverse($this->arResult);

        return $this->arResult;
    }