protected function createCategoryConstraint(QueryInterface $query, $categories, bool $includeSubCategories = false): array
    {
        $constraints = [];

        if ($includeSubCategories) {
            $categoryService = GeneralUtility::makeInstance(CategoryService::class);
            $allCategories = $categoryService->getChildrenCategories($categories);
            if (!\is_array($allCategories)) {
                $allCategories = GeneralUtility::intExplode(',', $allCategories, true);
            }
        } else {
            $allCategories = GeneralUtility::intExplode(',', $categories, true);
        }

        foreach ($allCategories as $category) {
            $constraints[] = $query->contains('categories', $category);
        }
        return $constraints;
    }
protected function createCategoryConstraint(QueryInterface $query, $categories, bool $includeSubCategories = false): array
    {
        $constraints = [];

        if ($includeSubCategories) {
            $categoryService = GeneralUtility::makeInstance(CategoryService::class);
            $allCategories = $categoryService->getChildrenCategories($categories);
            if (!\is_array($allCategories)) {
                $allCategories = GeneralUtility::intExplode(',', $allCategories, true);
            }
        } else {
            $allCategories = GeneralUtility::intExplode(',', $categories, true);
        }

        foreach ($allCategories as $category) {
            $constraints[] = $query->contains('categories', $category);
        }
        return $constraints;
    }
protected function createCategoryConstraint ( QueryInterface $ query , $ categories , bool $ includeSubCategories = false ) : array { $ constraints = [ ] ; if ( $ includeSubCategories ) { $ categoryService = GeneralUtility :: makeInstance ( CategoryService :: class ) ; $ allCategories = $ categoryService -> getChildrenCategories ( $ categories ) ; if ( ! \ is_array ( $ allCategories ) ) { $ allCategories = GeneralUtility :: intExplode ( ',' , $ allCategories , true ) ; } } else { $ allCategories = GeneralUtility :: intExplode ( ',' , $ categories , true ) ; } foreach ( $ allCategories as $ category ) { $ constraints [ ] = $ query -> contains ( 'categories' , $ category ) ; } return $ constraints ; }
Returns a category constraint created by
a given list of categories and a junction string

@param QueryInterface $query
@param string $categories
@param bool $includeSubCategories
@return array
@throws InvalidQueryException
Returns a category constraint created by a given list of categories and a junction string