protected function getChildrenCategoriesRecursive($idList, $counter = 0): string
    {
        $result = [];

        // add id list to the output
        if ($counter === 0) {
            $newList = $this->getUidListFromRecords($idList);
            if ($newList) {
                $result[] = $newList;
            }
        }

        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable('sys_category');
        $res = $queryBuilder
            ->select('uid')
            ->from('sys_category')
            ->where(
                $queryBuilder->expr()->in('parent', $queryBuilder->createNamedParameter(explode(',', $idList), Connection::PARAM_INT_ARRAY))
            )
            ->execute();

        while ($row = $res->fetch()) {
            $counter++;
            if ($counter > 10000) {
                $this->timeTracker->setTSlogMessage('EXT:tt_address: one or more recursive categories where found');
                return implode(',', $result);
            }
            $subcategories = $this->getChildrenCategoriesRecursive($row['uid'], $counter);
            $result[] = $row['uid'] . ($subcategories ? ',' . $subcategories : '');
        }

        $result = implode(',', $result);
        return $result;
    }
protected function getChildrenCategoriesRecursive($idList, $counter = 0): string
    {
        $result = [];

        // add id list to the output
        if ($counter === 0) {
            $newList = $this->getUidListFromRecords($idList);
            if ($newList) {
                $result[] = $newList;
            }
        }

        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable('sys_category');
        $res = $queryBuilder
            ->select('uid')
            ->from('sys_category')
            ->where(
                $queryBuilder->expr()->in('parent', $queryBuilder->createNamedParameter(explode(',', $idList), Connection::PARAM_INT_ARRAY))
            )
            ->execute();

        while ($row = $res->fetch()) {
            $counter++;
            if ($counter > 10000) {
                $this->timeTracker->setTSlogMessage('EXT:tt_address: one or more recursive categories where found');
                return implode(',', $result);
            }
            $subcategories = $this->getChildrenCategoriesRecursive($row['uid'], $counter);
            $result[] = $row['uid'] . ($subcategories ? ',' . $subcategories : '');
        }

        $result = implode(',', $result);
        return $result;
    }
protected function getChildrenCategoriesRecursive ( $ idList , $ counter = 0 ) : string { $ result = [ ] ; // add id list to the output if ( $ counter === 0 ) { $ newList = $ this -> getUidListFromRecords ( $ idList ) ; if ( $ newList ) { $ result [ ] = $ newList ; } } $ queryBuilder = GeneralUtility :: makeInstance ( ConnectionPool :: class ) -> getQueryBuilderForTable ( 'sys_category' ) ; $ res = $ queryBuilder -> select ( 'uid' ) -> from ( 'sys_category' ) -> where ( $ queryBuilder -> expr ( ) -> in ( 'parent' , $ queryBuilder -> createNamedParameter ( explode ( ',' , $ idList ) , Connection :: PARAM_INT_ARRAY ) ) ) -> execute ( ) ; while ( $ row = $ res -> fetch ( ) ) { $ counter ++ ; if ( $ counter > 10000 ) { $ this -> timeTracker -> setTSlogMessage ( 'EXT:tt_address: one or more recursive categories where found' ) ; return implode ( ',' , $ result ) ; } $ subcategories = $ this -> getChildrenCategoriesRecursive ( $ row [ 'uid' ] , $ counter ) ; $ result [ ] = $ row [ 'uid' ] . ( $ subcategories ? ',' . $ subcategories : '' ) ; } $ result = implode ( ',' , $ result ) ; return $ result ; }
Get child categories

@param string $idList list of category ids to start
@param int $counter
@return string comma separated list of category ids
Get child categories