src/KGzocha/Searcher/Chain/ChainSearch.php
public function search(
        CriteriaCollectionInterface $criteriaCollection
    ): ResultCollection {
        $previousCriteria = $criteriaCollection;
        $previousResults = null;
        $result = new ResultCollection();

        /** @var CellInterface $cell */
        foreach ($this->cellCollection as $name => $cell) {
            if ($cell->getTransformer()->skip($previousResults)) {
                continue;
            }

            $previousResults = $cell->getSearcher()->search($previousCriteria);
            $previousCriteria = $this->getNewCriteria(
                $cell,
                $previousCriteria,
                $previousResults
            );

            $result->addNamedItem((string) $name, $previousResults);
        }

        return $result;
    }
public function search(
        CriteriaCollectionInterface $criteriaCollection
    ): ResultCollection {
        $previousCriteria = $criteriaCollection;
        $previousResults = null;
        $result = new ResultCollection();

        /** @var CellInterface $cell */
        foreach ($this->cellCollection as $name => $cell) {
            if ($cell->getTransformer()->skip($previousResults)) {
                continue;
            }

            $previousResults = $cell->getSearcher()->search($previousCriteria);
            $previousCriteria = $this->getNewCriteria(
                $cell,
                $previousCriteria,
                $previousResults
            );

            $result->addNamedItem((string) $name, $previousResults);
        }

        return $result;
    }
public function search ( CriteriaCollectionInterface $ criteriaCollection ) : ResultCollection { $ previousCriteria = $ criteriaCollection ; $ previousResults = null ; $ result = new ResultCollection ( ) ; /** @var CellInterface $cell */ foreach ( $ this -> cellCollection as $ name => $ cell ) { if ( $ cell -> getTransformer ( ) -> skip ( $ previousResults ) ) { continue ; } $ previousResults = $ cell -> getSearcher ( ) -> search ( $ previousCriteria ) ; $ previousCriteria = $ this -> getNewCriteria ( $ cell , $ previousCriteria , $ previousResults ) ; $ result -> addNamedItem ( ( string ) $ name , $ previousResults ) ; } return $ result ; }
Will perform multiple sub-searches.
Results from first search will be transformed and passed as CriteriaCollection
to another sub-search.
Whole process will return collection of results from each sub-search.

@param CriteriaCollectionInterface $criteriaCollection

@return ResultCollection
Will perform multiple sub - searches . Results from first search will be transformed and passed as CriteriaCollection to another sub - search . Whole process will return collection of results from each sub - search .