first commit
This commit is contained in:
@@ -32,7 +32,7 @@ use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* A ResultParser is responsible to create the result object structure from the \Apache_Solr_Response
|
||||
* A ResultParser is responsible to create the result object structure from the \Apache_Meilisearch_Response
|
||||
* and assign it to the SearchResultSet.
|
||||
*/
|
||||
abstract class AbstractResultParser {
|
||||
|
@@ -62,7 +62,7 @@ class DefaultResultParser extends AbstractResultParser {
|
||||
}
|
||||
|
||||
foreach ($documents as $searchResult) {
|
||||
$searchResultObject = $this->searchResultBuilder->fromApacheSolrDocument($searchResult);
|
||||
$searchResultObject = $this->searchResultBuilder->fromApacheMeilisearchDocument($searchResult);
|
||||
$searchResults[] = $searchResultObject;
|
||||
}
|
||||
|
||||
|
@@ -26,11 +26,11 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result\Parser;
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
use WapplerSystems\Meilisearch\Util;
|
||||
|
||||
/**
|
||||
* Applies htmlspecialschars on documents of a solr response.
|
||||
* Applies htmlspecialschars on documents of a meilisearch response.
|
||||
*/
|
||||
class DocumentEscapeService {
|
||||
|
||||
@@ -44,7 +44,7 @@ class DocumentEscapeService {
|
||||
* @param TypoScriptConfiguration|null $typoScriptConfiguration
|
||||
*/
|
||||
public function __construct(TypoScriptConfiguration $typoScriptConfiguration = null) {
|
||||
$this->typoScriptConfiguration = $typoScriptConfiguration ?? Util::getSolrConfiguration();
|
||||
$this->typoScriptConfiguration = $typoScriptConfiguration ?? Util::getMeilisearchConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,13 +56,13 @@ class DocumentEscapeService {
|
||||
*/
|
||||
public function applyHtmlSpecialCharsOnAllFields(array $documents)
|
||||
{
|
||||
$trustedSolrFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();
|
||||
$trustedMeilisearchFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();
|
||||
|
||||
foreach ($documents as $key => $document) {
|
||||
$fieldNames = array_keys($document->getFields() ?? []);
|
||||
|
||||
foreach ($fieldNames as $fieldName) {
|
||||
if (is_array($trustedSolrFields) && in_array($fieldName, $trustedSolrFields)) {
|
||||
if (is_array($trustedMeilisearchFields) && in_array($fieldName, $trustedMeilisearchFields)) {
|
||||
// we skip this field, since it was marked as secure
|
||||
continue;
|
||||
}
|
||||
|
@@ -26,10 +26,10 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result;
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping\GroupItem;
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
|
||||
/**
|
||||
* Solr document class that should be used in the frontend in the search context.
|
||||
* Meilisearch document class that should be used in the frontend in the search context.
|
||||
*
|
||||
* @author Timo Schmidt <timo.schmidt@dkd.de>
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ class SearchResult extends Document
|
||||
/**
|
||||
* The variant field value
|
||||
*
|
||||
* Value of Solr collapse field, which is defined via
|
||||
* Value of Meilisearch collapse field, which is defined via
|
||||
* TypoScript variable "variants.variantField"
|
||||
*
|
||||
* @var string
|
||||
|
@@ -25,24 +25,24 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* The SearchResultBuilder is responsible to build a SearchResult object from an \WapplerSystems\Meilisearch\System\Solr\Document\Document
|
||||
* The SearchResultBuilder is responsible to build a SearchResult object from an \WapplerSystems\Meilisearch\System\Meilisearch\Document\Document
|
||||
* and should use a different class as SearchResult if configured.
|
||||
*/
|
||||
class SearchResultBuilder {
|
||||
|
||||
/**
|
||||
* This method is used to wrap the original solr document instance in an instance of the configured SearchResult
|
||||
* This method is used to wrap the original meilisearch document instance in an instance of the configured SearchResult
|
||||
* class.
|
||||
*
|
||||
* @param Document $originalDocument
|
||||
* @throws \InvalidArgumentException
|
||||
* @return SearchResult
|
||||
*/
|
||||
public function fromApacheSolrDocument(Document $originalDocument)
|
||||
public function fromApacheMeilisearchDocument(Document $originalDocument)
|
||||
{
|
||||
|
||||
$searchResultClassName = $this->getResultClassName();
|
||||
@@ -60,7 +60,7 @@ class SearchResultBuilder {
|
||||
*/
|
||||
protected function getResultClassName()
|
||||
{
|
||||
return isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName ']) ?
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName '] : SearchResult::class;
|
||||
return isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['searchResultClassName ']) ?
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['searchResultClassName '] : SearchResult::class;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user