protected function addDocumentsWhenLimitNotReached(array $documents, SearchResultCollection $documentsToAdd, int $maxDocuments)  : array
    {
        $additionalTopResultsFields = $this->typoScriptConfiguration->getSuggestAdditionalTopResultsFields();
        /** @var SearchResult $document */
        foreach ($documentsToAdd as $document) {
            $documents[] = $this->getDocumentAsArray($document, $additionalTopResultsFields);
            if (count($documents) >= $maxDocuments) {
                return $documents;
            }
        }

        return $documents;
    }
protected function addDocumentsWhenLimitNotReached(array $documents, SearchResultCollection $documentsToAdd, int $maxDocuments)  : array
    {
        $additionalTopResultsFields = $this->typoScriptConfiguration->getSuggestAdditionalTopResultsFields();
        /** @var SearchResult $document */
        foreach ($documentsToAdd as $document) {
            $documents[] = $this->getDocumentAsArray($document, $additionalTopResultsFields);
            if (count($documents) >= $maxDocuments) {
                return $documents;
            }
        }

        return $documents;
    }
protected function addDocumentsWhenLimitNotReached ( array $ documents , SearchResultCollection $ documentsToAdd , int $ maxDocuments ) : array { $ additionalTopResultsFields = $ this -> typoScriptConfiguration -> getSuggestAdditionalTopResultsFields ( ) ; /** @var SearchResult $document */ foreach ( $ documentsToAdd as $ document ) { $ documents [ ] = $ this -> getDocumentAsArray ( $ document , $ additionalTopResultsFields ) ; if ( count ( $ documents ) >= $ maxDocuments ) { return $ documents ; } } return $ documents ; }
Adds documents from a collection to the result collection as soon as the limit is not reached.

@param array $documents
@param SearchResultCollection $documentsToAdd
@param integer $maxDocuments
@return array
Adds documents from a collection to the result collection as soon as the limit is not reached .