Returns categories tree

@param int    $limit
@param string $orderBy
@param string $orderDir

@return array
437222
public function getCategoriesTree($limit = 1000, $orderBy = 'hierarchy', $orderDir = 'asc')
    {
        return $this->dataset->getResult('tree', [
            'limit'     => $limit,
            'order_by'  => $orderBy,
            'order_dir' => $orderDir
        ]);
    }
651956
static public function listSortForMany($list, $orderBy)
    {
        if (!is_array($list) || !$orderBy) {
            return $list;
        }

        if (is_string($orderBy)) {
            $orderBy = explode(',',$orderBy);
        }

        list($key,$sort) = explode(' ',reset($orderBy));

        $arr = [];
        foreach ($list as $row) {
            $arr[$row[$key]][] = $row;
        }

        if ($sort == "desc") {
            krsort($arr);
        }else{
            ksort($arr);
        }

        array_shift($orderBy);

        if (!empty($orderBy)) {
            foreach ($arr as &$row) {
                $row = self::listSortForMany($row,$orderBy);
            }
        }

        return (count($arr) >= 1) ? array_merge(...array_values($arr)) : $arr;
    }
939197
protected function getIDListChildrenCategory($iCategoryID) : array
    {
        //Get category item
        $obCategoryItem = CategoryItem::make($iCategoryID);
        if ($obCategoryItem->isEmpty() || $obCategoryItem->children->isEmpty()) {
            return [];
        }

        $arResultIDList = [];
        foreach ($obCategoryItem->children as $obChildCategoryItem) {
            $arResultIDList = array_merge($arResultIDList, (array) ProductListStore::instance()->category->get($obChildCategoryItem->id));
            $arResultIDList = array_merge($arResultIDList, $this->getIDListChildrenCategory($obChildCategoryItem->id));
        }

        return $arResultIDList;
    }
231930
function getTree($gets,$category='fid',$order='id desc')
	{
		$gets['order'] = $category . ',' . $order;
		$list = $this->gets($gets);
		foreach ($list as $li)
		{
			if ($li[$category] == 0)
			{
				$new[$li[$this->primary]] = $li;
			}
			else
			{
				$new[$li[$category]]['child'][$li[$this->primary]] = $li;
			}
		}
		return $new;
	}
306399
public function findManyBy($key, $value,  $orderBy = null, $limit = null, $offset = null){
        return $this->findMany($key.'=:key', array(':key' => $value), $orderBy, $limit, $offset);
    }
18257
public static function findAllArray($condition = [],$orderBy = []) {
        return self::find()->where($condition)->asArray()->orderBy($orderBy)->all(static::getDb());
    }
797939
public function findBy(
        array $criteria,
        ?array $orderBy = null,
        ?int $limit = null,
        ?int $offset = null
    ) : array {
        $objects = [];

        foreach ($this->objects as $object) {
            $matches = true;

            foreach ($criteria as $key => $value) {
                if ($object[$key] === $value) {
                    continue;
                }

                $matches = false;
            }

            if (! $matches) {
                continue;
            }

            $objects[] = $object;
        }

        return $objects;
    }
26463
protected function getListCategoryGroup()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            return $this->category_group->getList(array('limit' => $this->getLimit()));
        }

        if ($this->getParam('type')) {
            return $this->category_group->getList(array('type' => $id, 'limit' => $this->getLimit()));
        }

        if (!is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        if ($this->getParam('store')) {
            return $this->category_group->getList(array('store_id' => $id, 'limit' => $this->getLimit()));
        }

        $result = $this->category_group->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
1206806
protected function getListCategory()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            return $this->category->getList(array('limit' => $this->getLimit()));
        }

        if (!is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        if ($this->getParam('group')) {
            return $this->category->getList(array('category_group_id' => $id, 'limit' => $this->getLimit()));
        }

        if ($this->getParam('parent')) {
            return $this->category->getList(array('parent_id' => $id, 'limit' => $this->getLimit()));
        }

        $result = $this->category->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
962674
protected function getListLogOrder(array $limit)
    {
        $conditions = array(
            'limit' => $limit,
            'order_id' => $this->data_order['order_id']
        );

        return (array) $this->order_history->getList($conditions);
    }
1200452
public function getTotalResult($start, $limit, $sortBy, $sortOrder, $params)
    {
        $results = $this->findAll($start, $limit, $sortBy, $sortOrder, $params);

        return count($results);
    }
814696
public function getCategoryFlatTree($parentCategoryId = null, $categoryTypeKey = null)
    {
        $flatTree = [];
        //budowanie płaskie drzewo
        $this->_buildFlatTree('', $flatTree, $this->getCategoryTree($parentCategoryId), $categoryTypeKey);
        return $flatTree;
    }
1368204
public function sortCollection(Collection $collection, $orderBy, $orderDir = 'asc', $orderManual = null, $sort_flags = null)
    {
        $items = $collection->toArray();
        if (!$items) {
            return [];
        }

        $lookup = md5(json_encode($items) . json_encode($orderManual) . $orderBy . $orderDir);
        if (!isset($this->sort[$lookup][$orderBy])) {
            $this->buildSort($lookup, $items, $orderBy, $orderManual, $sort_flags);
        }

        $sort = $this->sort[$lookup][$orderBy];

        if ($orderDir !== 'asc') {
            $sort = array_reverse($sort);
        }

        return $sort;

    }
1254922
protected function getCategoryTitle(CategoryInterface $category, $limit = 500)
    {
        $count = $this->categoryManager->getProductCount($category, $limit);

        return sprintf('%s <span class="badge pull-right">%d%s</span>', $category->getName(), $count, $count > $limit ? '+' : '');
    }
730584
public function &GetFieldShopCategoryList($sOrderBy = '')
    {
        $oCategories = &$this->GetFromInternalCache('oCategories');
        if (is_null($oCategories)) {
            $oCategories = &TdbShopCategoryList::GetArticleCategories($this->id, $this->iLanguageId);
            $this->SetInternalCache('oCategories', $oCategories);
        }

        return $oCategories;
    }
878434
public function search($term, $limit, $offset, $orderBy = null)
    {
        $qb = $this->createQueryBuilder('m');

        $qb->where('m.name LIKE :term')
            ->andWhere('m.status IN (:statuses)')
            ->setParameters(array(
                'term' => '%'.$term.'%',
                'statuses' => array(0, 1),
            )
        );

        if ($limit) {
            $qb->setMaxResults($limit);
        }

        if ($offset) {
            $qb->setFirstResult($offset);
        }

        return $qb->getQuery()->getResult();
    }
1121262
public static function fetch_course_tree($courseid, $include_category_items=false) {
        $course_category = grade_category::fetch_course_category($courseid);
        $category_array = array('object'=>$course_category, 'type'=>'category', 'depth'=>1,
                                'children'=>$course_category->get_children($include_category_items));

        $course_category->sortorder = $course_category->get_sortorder();
        $sortorder = $course_category->get_sortorder();
        return grade_category::_fetch_course_tree_recursion($category_array, $sortorder);
    }