private function addChildrenQueries($query, CategoryInterface $category, $excludedCategories = [])
    {
        $childrenCategories    = $this->getChildrenCategories($category, $excludedCategories);
        $childrenCategoriesIds = [];

        if ($childrenCategories->getSize() > 0 && $query !== null) {
            $queryParams = ['should' => [$query], 'cached' => empty($excludedCategories)];

            foreach ($childrenCategories as $childrenCategory) {
                if (((bool) $childrenCategory->getIsVirtualCategory()) === true) {
                    $childrenQuery = $this->getCategorySearchQuery($childrenCategory, $excludedCategories);
                    if ($childrenQuery !== null) {
                        $queryParams['should'][] = $childrenQuery;
                    }
                } else {
                    $childrenCategoriesIds[] = $childrenCategory->getId();
                }
            }

            if (!empty($childrenCategoriesIds)) {
                $queryParams['should'][] = $this->getStandardCategoriesQuery($childrenCategoriesIds, $excludedCategories);
            }

            if (count($queryParams['should']) > 1) {
                $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, $queryParams);
            }
        }

        return $query;
    }
private function addChildrenQueries($query, CategoryInterface $category, $excludedCategories = [])
    {
        $childrenCategories    = $this->getChildrenCategories($category, $excludedCategories);
        $childrenCategoriesIds = [];

        if ($childrenCategories->getSize() > 0 && $query !== null) {
            $queryParams = ['should' => [$query], 'cached' => empty($excludedCategories)];

            foreach ($childrenCategories as $childrenCategory) {
                if (((bool) $childrenCategory->getIsVirtualCategory()) === true) {
                    $childrenQuery = $this->getCategorySearchQuery($childrenCategory, $excludedCategories);
                    if ($childrenQuery !== null) {
                        $queryParams['should'][] = $childrenQuery;
                    }
                } else {
                    $childrenCategoriesIds[] = $childrenCategory->getId();
                }
            }

            if (!empty($childrenCategoriesIds)) {
                $queryParams['should'][] = $this->getStandardCategoriesQuery($childrenCategoriesIds, $excludedCategories);
            }

            if (count($queryParams['should']) > 1) {
                $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, $queryParams);
            }
        }

        return $query;
    }
private function addChildrenQueries ( $ query , CategoryInterface $ category , $ excludedCategories = [ ] ) { $ childrenCategories = $ this -> getChildrenCategories ( $ category , $ excludedCategories ) ; $ childrenCategoriesIds = [ ] ; if ( $ childrenCategories -> getSize ( ) > 0 && $ query !== null ) { $ queryParams = [ 'should' => [ $ query ] , 'cached' => empty ( $ excludedCategories ) ] ; foreach ( $ childrenCategories as $ childrenCategory ) { if ( ( ( bool ) $ childrenCategory -> getIsVirtualCategory ( ) ) === true ) { $ childrenQuery = $ this -> getCategorySearchQuery ( $ childrenCategory , $ excludedCategories ) ; if ( $ childrenQuery !== null ) { $ queryParams [ 'should' ] [ ] = $ childrenQuery ; } } else { $ childrenCategoriesIds [ ] = $ childrenCategory -> getId ( ) ; } } if ( ! empty ( $ childrenCategoriesIds ) ) { $ queryParams [ 'should' ] [ ] = $ this -> getStandardCategoriesQuery ( $ childrenCategoriesIds , $ excludedCategories ) ; } if ( count ( $ queryParams [ 'should' ] ) > 1 ) { $ query = $ this -> queryFactory -> create ( QueryInterface :: TYPE_BOOL , $ queryParams ) ; } } return $ query ; }
Append children queries to the rule.

@SuppressWarnings(PHPMD.ElseExpression)

@param QueryInterface|NULL $query              Base query.
@param CategoryInterface   $category           Current cayegory.
@param array               $excludedCategories Category already used into the building stack. Avoid short circuit.

@return \Smile\ElasticsuiteCore\Search\Request\QueryInterface
Append children queries to the rule .