ChannelApiModel::getAllChannel PHP Method

getAllChannel() public method

获取所有频道分类数据
public getAllChannel ( $uid ) : array
return array 所有频道分类数据
    public function getAllChannel($uid)
    {
        $data = model('CategoryTree')->setTable('channel_category')->getCategoryAllHash();
        // 组装附件信息
        $attachIds = getSubByKey($data, 'attach');
        $attachIds = array_filter($attachIds);
        $attachIds = array_unique($attachIds);
        $attachInfos = model('Attach')->getAttachByIds($attachIds);
        $attachData = array();
        foreach ($attachInfos as $attach) {
            $attachData[$attach['attach_id']] = $attach;
        }
        foreach ($data as &$value) {
            if (!empty($value['attach']) && !empty($attachData[$value['attach']])) {
                $value['icon_url'] = getImageUrl($attachData[$value['attach']]['save_path'] . $attachData[$value['attach']]['save_name']);
            } else {
                $value['icon_url'] = null;
            }
            unset($value['ext'], $value['attach'], $value['user_bind'], $value['topic_bind']);
            if ($uid) {
                $value['followStatus'] = intval(D('ChannelFollow', 'channel')->getFollowStatus($uid, $value['channel_category_id']));
            }
        }
        return $data;
    }