diff --git a/Classes/Domain/Search/ResultSet/Grouping/Parser/GroupedResultParser.php b/Classes/Domain/Search/ResultSet/Grouping/Parser/GroupedResultParser.php index 968786a..fd9eb1d 100644 --- a/Classes/Domain/Search/ResultSet/Grouping/Parser/GroupedResultParser.php +++ b/Classes/Domain/Search/ResultSet/Grouping/Parser/GroupedResultParser.php @@ -30,9 +30,11 @@ use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping\GroupItem; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping\GroupItemCollection; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\Parser\AbstractResultParser; +use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResult; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResultCollection; use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest; +use ApacheSolrForTypo3\Solr\System\Solr\Document\Document; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -237,7 +239,7 @@ protected function buildGroupItemAndAddDocuments(SearchRequest $searchRequest, G $relevantResults = array_slice($rawGroup->doclist->docs, $offset, $perPage); foreach ($relevantResults as $rawDoc) { - $solrDocument = new \Apache_Solr_Document(); + $solrDocument = new Document(); foreach(get_object_vars($rawDoc) as $key => $value) { $solrDocument->setField($key, $value); } diff --git a/Classes/Query/Modifier/Grouping.php b/Classes/Query/Modifier/Grouping.php index ca25f36..57f88b9 100644 --- a/Classes/Query/Modifier/Grouping.php +++ b/Classes/Query/Modifier/Grouping.php @@ -24,10 +24,13 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use ApacheSolrForTypo3\Solr\Domain\Search\Query\ParameterBuilder\Grouping as GroupingParameter; +use ApacheSolrForTypo3\Solr\Domain\Search\Query\QueryBuilder; +use ApacheSolrForTypo3\Solr\Domain\Search\Query\Query; use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest; use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequestAware; -use ApacheSolrForTypo3\Solr\Domain\Search\Query\Query; use ApacheSolrForTypo3\Solr\Query\Modifier\Modifier; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -43,6 +46,22 @@ class Grouping implements Modifier, SearchRequestAware */ protected $searchRequest; + /** + * QueryBuilder + * + * @var QueryBuilder|object + */ + protected $queryBuilder; + + /** + * AccessComponent constructor. + * @param QueryBuilder|null + */ + public function __construct(QueryBuilder $queryBuilder = null) + { + $this->queryBuilder = $queryBuilder ?? GeneralUtility::makeInstance(QueryBuilder::class); + } + /** * @param SearchRequest $searchRequest */ @@ -65,8 +84,8 @@ public function modifyQuery(Query $query) return $query; } - $grouping = $query->getGrouping(); - $grouping->setIsEnabled(true); + $grouping = new GroupingParameter(true); + $groupingConfiguration = $this->searchRequest->getContextTypoScriptConfiguration()->getObjectByPathOrDefault('plugin.tx_solr.search.grouping.', []); @@ -103,6 +122,8 @@ public function modifyQuery(Query $query) } } + $query = $this->queryBuilder->startFrom($query)->useGrouping($grouping)->getQuery(); + return $query; } } diff --git a/Tests/Unit/Domain/Search/ResultSet/Grouping/Parser/GroupedResultsParserTest.php b/Tests/Unit/Domain/Search/ResultSet/Grouping/Parser/GroupedResultsParserTest.php index e7d19a9..2b27ed0 100644 --- a/Tests/Unit/Domain/Search/ResultSet/Grouping/Parser/GroupedResultsParserTest.php +++ b/Tests/Unit/Domain/Search/ResultSet/Grouping/Parser/GroupedResultsParserTest.php @@ -17,6 +17,7 @@ use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet; use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest; use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; +use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter; use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest; use ApacheSolrForTypo3\Solrfluidgrouping\Domain\Search\ResultSet\Grouping\Parser\GroupedResultParser; @@ -117,13 +118,11 @@ protected function getSearchResultSetMockFromConfigurationAndFixtureFileName(Typ /** * @param $fixtureFile - * @return \Apache_Solr_Response + * @return ResponseAdapter */ protected function getFakeApacheSolrResponse($fixtureFile) { $fakeResponseJson = $this->getFixtureContentByName($fixtureFile); - $httpResponseMock = $this->getDumbMock('\Apache_Solr_HttpTransport_Response'); - $httpResponseMock->expects($this->any())->method('getBody')->will($this->returnValue($fakeResponseJson)); - return new \Apache_Solr_Response($httpResponseMock); + return new ResponseAdapter($fakeResponseJson); } } \ No newline at end of file diff --git a/Tests/Unit/Domain/Search/ResultSet/SearchResultSetServiceTest.php b/Tests/Unit/Domain/Search/ResultSet/SearchResultSetServiceTest.php index a3d19f3..faf1fb8 100644 --- a/Tests/Unit/Domain/Search/ResultSet/SearchResultSetServiceTest.php +++ b/Tests/Unit/Domain/Search/ResultSet/SearchResultSetServiceTest.php @@ -20,6 +20,7 @@ use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequest; use ApacheSolrForTypo3\Solr\Search; use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration; +use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter; use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest; use ApacheSolrForTypo3\Solrfluidgrouping\Domain\Search\ResultSet\Grouping\Parser\GroupedResultParser; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -107,15 +108,11 @@ public function canCreateGroups() /** * @param $fixtureFile - * @return \Apache_Solr_Response + * @return ResponseAdapter */ protected function getFakeApacheSolrResponse($fixtureFile) { $fakeResponseJson = $this->getFixtureContentByName($fixtureFile); - $httpResponseMock = $this->getDumbMock('\Apache_Solr_HttpTransport_Response'); - $httpResponseMock->expects($this->any())->method('getBody')->will($this->returnValue($fakeResponseJson)); - - - return new \Apache_Solr_Response($httpResponseMock); + return new ResponseAdapter($fakeResponseJson); } } diff --git a/ext_emconf.php b/ext_emconf.php index 5e74b93..899ab15 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -16,7 +16,7 @@ 'constraints' => array( 'depends' => array( 'scheduler' => '', - 'solr' => '8.0.1-', + 'solr' => '9.0.0-', 'extbase' => '8.7.0-9.3.99', 'fluid' => '8.7.0-9.3.99', 'typo3' => '8.7.0-9.3.99'