Skip to content

Commit

Permalink
Merge pull request #16 from timohund/task/master/15-support-ext-solr-…
Browse files Browse the repository at this point in the history
…9-with-solarium

[TASK] Support EXT:solr 9 with solarium
  • Loading branch information
timohund authored Aug 14, 2018
2 parents 2cbfdf2 + e27c91d commit 5ab1e85
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
Expand Down
27 changes: 24 additions & 3 deletions Classes/Query/Modifier/Grouping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand All @@ -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
*/
Expand All @@ -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.', []);

Expand Down Expand Up @@ -103,6 +122,8 @@ public function modifyQuery(Query $query)
}
}

$query = $this->queryBuilder->startFrom($query)->useGrouping($grouping)->getQuery();

return $query;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 5ab1e85

Please sign in to comment.