skeeks\cms\cmsWidgets\contentElements\ContentElementsCmsWidget::getAllIdsForChildren PHP Method

getAllIdsForChildren() public method

public getAllIdsForChildren ( Tree $tree ) : array
$tree skeeks\cms\models\Tree
return array
    public function getAllIdsForChildren(Tree $tree)
    {
        $treeIds = [];
        /**
         * @var $query ActiveQuery
         */
        $childrens = $tree->getChildren()->with('children')->all();
        if ($childrens) {
            foreach ($childrens as $chidren) {
                if ($chidren->children) {
                    $treeIds[$chidren->id] = $chidren->id;
                    $treeIds = array_merge($treeIds, $this->getAllIdsForChildren($chidren));
                } else {
                    $treeIds[$chidren->id] = $chidren->id;
                }
            }
        }
        return $treeIds;
    }