store\components\behaviors\DCategoryTreeBehavior::getMenuList PHP Method

getMenuList() public method

Returns items for zii.widgets.CMenu widget
public getMenuList ( integer $sub, mixed $parent ) : array
$sub integer levels
$parent mixed number, object or array of numbers
return array
    public function getMenuList($sub = 0, $parent = 0)
    {
        $criteria = $this->getOwnerCriteria();
        if (!$parent) {
            $parent = $this->getOwner()->getPrimaryKey();
        }
        if ($parent) {
            $criteria->compare($this->primaryKeyAttribute, $this->getChildsArray($parent));
        }
        $items = $this->cached($this->getOwner())->findAll($criteria);
        $categories = [];
        foreach ($items as $item) {
            $categories[(int) $item->{$this->parentAttribute}][] = $item;
        }
        return $this->_getMenuListRecursive($categories, $parent, $sub);
    }