Gets the categories
@param mixed $blog_id ID of the blog
@return array Array of categories
772724
protected function getCategories($blog_id) {
        $categories=array();
        
        
        //If we have a SiteTree class add the classes
        if(class_exists('SiteTree')) {
            $pageClasses=ClassInfo::subclassesFor('SiteTree');
            foreach($pageClasses as $class) {
                if($class!='SiteTree') {
                    $categories[]=array(
                                    'categoryId'=>'ss_'.strtolower($class),
                                    'categoryName'=>singleton($class)->i18n_singular_name(),
                                    'parentId'=>0
                                );
                }
            }
        }
        
        
        $results=$this->extend('getCategories', $blog_id);
        if($results && is_array($results)) {
            $results=array_filter($results, function($v) {return !is_null($v);});
            
            if(count($results)>0) {
                for($i=0;$i<count($results);$i++) {
                    $categories=array_merge($categories, $results[$i]);
                }
            }
        }
        
        
        return $categories;
    }
1213139
def blog__get_categories(
      order: nil,
      language: nil,
      search: nil,
      page: nil,
      per_page: nil
    )
      categories = LatoBlog::Category.all

      # apply filters
      order = order && order == 'ASC' ? 'ASC' : 'DESC'
      categories = _categories_filter_by_order(categories, order)
      categories = _categories_filter_by_language(categories, language)
      categories = _categories_filter_search(categories, search)

      # take categories uniqueness
      categories = categories.uniq(&:id)

      # save total categories
      total = categories.length

      # manage pagination
      page = page&.to_i || 1
      per_page = per_page&.to_i || 20
      categories = core__paginate_array(categories, per_page, page)

      # return result
      {
        categories: categories && !categories.empty? ? categories.map(&:serialize) : [],
        page: page,
        per_page: per_page,
        order: order,
        total: total
      }
    end
37429
public Category getCategory(int pageId) {
        long hibernateId = __getCategoryHibernateId(pageId);
        if (hibernateId == -1) {
            return null;
        }

        try {
            Category cat = new Category(this, hibernateId);
            return cat;
        } catch (WikiPageNotFoundException e) {
            return null;
        }
    }
44785
public function actionGetCategoryUrls(string $category, array $criteria = [], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId));
    }
103716
public static function get_site_categories() {
        global $DB;

        if (method_exists('\core_course_category', 'get_all')) {
            $categories = \core_course_category::get_all(['returnhidden' => true]);
        } else {
            // Fallback (to be removed once this gets integrated into master).
            $ids = $DB->get_fieldset_select('course_categories', 'id', '');
            $categories = \core_course_category::get_many($ids);
        }

        foreach ($categories as $key => $category) {
            if (!$category->is_uservisible()) {
                unset($categories[$key]);
            }
        }
        return $categories;
    }
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 '';
    }
1018324
def get_category(self, id, **data):
        
        
        return self.get("/categories/{0}/".format(id), data=data)
591605
private function getCategory($categoryId)
    {
        if (!array_key_exists($categoryId, $this->categories)) {
            $categoryCollection = $this->categoryCollectionFactory->create();
            foreach ($categoryCollection as $category) {
                $this->categories[$category->getId()] = $category;
            }
        }

        return $this->categories[$categoryId];
    }
1127812
private function getCategory()
    {
        $storeId    = $this->getStoreId();
        $categoryId = $this->getCategoryId();
        $category   = null;

        if ($this->getCategoryId()) {
            $category = $this->categoryRepository->get($categoryId, $storeId);
        }

        return $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));
    }
59844
public function getCategoryIds()
    {
        return array_keys((new CmsCategoryRelationQuery)
                ->join('cms_category')->on('cms_category_id')
                ->whereObject()->equals($this->_object)
                ->andFieldObjectId()->equals($this->_objectId)
                ->findPairs('cms_category.id', 'cms_category.id'));
    }
1221569
public function indexCategory($category_id)
    {
        $this->setCategory($category_id);
        $this->setTitleIndexCategory();
        $this->setBreadcrumbIndexCategory();
        $this->setHtmlFilterIndexCategory();
        $this->setTotalIndexCategory();
        $this->setFilterIndexCategory();
        $this->setPagerIndexCategory();
        $this->setListProductCategory();
        $this->setChildrenCategory();

        $this->setData('category', $this->data_category);

        $this->setDataMenuIndexCategory();
        $this->setDataImagesIndexCategory();
        $this->setDataNavbarIndexCategory();
        $this->setDataProductsIndexCategory();
        $this->setDataChildrenIndexCategory();

        $this->setMetaIndexCategory();
        $this->outputIndexCategory();
    }
578589
public function getActiveCategoryIdList( $categoryId, $parentType ) {

		$modelClass	= static::$modelClass;

		$models = $modelClass::findActiveByCategoryIdParentType( $categoryId, $parentType );
		$ids	= [];

		foreach ( $models as $model ) {

			$category = $model->category;

			$ids[] = $category->id;
		}

		return $ids;
	}
40371
public function addCategory(BlogCategory $category)
    {
        $category->setBlog($this);
        $this->categories->add($category);

        return $this;
    }
562998
private static function get_site_active_plugins( $blog_id = 0 ) {
            $active_basenames = ( is_multisite() && $blog_id > 0 ) ?
                get_blog_option( $blog_id, 'active_plugins' ) :
                get_option( 'active_plugins' );

            $active = array();

            if ( ! is_array( $active_basenames ) ) {
                return $active;
            }

            foreach ( $active_basenames as $basename ) {
                $active[ $basename ] = array(
                    'is_active' => true,
                    'Version'   => '1.0', // Dummy version.
                    'slug'      => self::get_plugin_slug( $basename ),
                );
            }

            return $active;
        }
102101
public function getUserRoles($user_id)
    {
        $roles = array();

        foreach ((array) get_sites() as $site) {

            //Get user role
            if ($site->blog_id != 1) {
                $userSettings = get_user_meta($user_id, $this->db->prefix . $site->blog_id . '_capabilities', true);
            } else {
                $userSettings = get_user_meta($user_id, $this->db->prefix . 'capabilities', true);
            }

            //Store to settings array
            if (is_array($userSettings)) {
                $roles[$site->blog_id] = key($userSettings);
            } else {
                $roles[$site->blog_id] = false;
            }
        }

        return $roles;
    }
376794
protected function get_context_by_category_id($category) {
        global $DB;
        $contextid = $DB->get_field('question_categories', 'contextid', array('id'=>$category));
        $context = context::instance_by_id($contextid, IGNORE_MISSING);
        return $context;
    }