BlogCategory::_getCategoryList PHP Метод

_getCategoryList() защищенный Метод

カテゴリリストを取得する(再帰処理)
protected _getCategoryList ( integer $blogContentId, integer $id = null, integer $viewCount = false, integer $depth = 1, integer $current = 1, array $fields = [] ) : array
$blogContentId integer
$id integer
$viewCount integer
$depth integer
$current integer
$fields array
Результат array
    protected function _getCategoryList($blogContentId, $id = null, $viewCount = false, $depth = 1, $current = 1, $fields = [])
    {
        $datas = $this->find('all', ['conditions' => ['BlogCategory.blog_content_id' => $blogContentId, 'BlogCategory.parent_id' => $id], 'fields' => $fields, 'recursive' => -1]);
        if ($datas) {
            foreach ($datas as $key => $data) {
                if ($viewCount) {
                    $datas[$key]['BlogCategory']['count'] = $this->BlogPost->find('count', ['conditions' => am(['BlogPost.blog_category_id' => $data['BlogCategory']['id']], $this->BlogPost->getConditionAllowPublish()), 'cache' => false]);
                }
                if ($current < $depth) {
                    $children = $this->_getCategoryList($blogContentId, $data['BlogCategory']['id'], $viewCount, $depth, $current + 1);
                    if ($children) {
                        $datas[$key]['BlogCategory']['children'] = $children;
                    }
                }
            }
        }
        return $datas;
    }