first commit

This commit is contained in:
Sven Wappler
2021-04-24 04:44:44 +02:00
parent cadcc8edb4
commit 2c9e27b3b7
55 changed files with 333 additions and 3877 deletions

View File

@@ -69,6 +69,11 @@ class MeilisearchConnection
*/
protected $configuration;
/**
* @var array
*/
protected $siteConfiguration;
/**
* @var SynonymParser
*/
@@ -85,9 +90,9 @@ class MeilisearchConnection
protected $schemaParser = null;
/**
* @var Client[]
* @var Client
*/
protected $nodes = [];
protected $client ;
/**
* @var MeilisearchLogManager
@@ -104,15 +109,6 @@ class MeilisearchConnection
*/
protected $psr7Client;
/**
* @var RequestFactoryInterface
*/
protected $requestFactory;
/**
* @var StreamFactoryInterface
*/
protected $streamFactory;
/**
* @var EventDispatcherInterface
@@ -122,8 +118,8 @@ class MeilisearchConnection
/**
* Constructor
*
* @param Client $readNode
* @param Client $writeNode
* @param Client $client
* @param array $siteConfiguration
* @param ?TypoScriptConfiguration $configuration
* @param ?SynonymParser $synonymParser
* @param ?StopWordParser $stopWordParser
@@ -138,8 +134,8 @@ class MeilisearchConnection
* @throws NotFoundExceptionInterface
*/
public function __construct(
Client $readNode,
Client $writeNode,
Client $client,
array $siteConfiguration,
TypoScriptConfiguration $configuration = null,
SynonymParser $synonymParser = null,
StopWordParser $stopWordParser = null,
@@ -148,9 +144,8 @@ class MeilisearchConnection
ClientInterface $psr7Client = null,
EventDispatcherInterface $eventDispatcher = null
) {
$this->nodes['read'] = $readNode;
$this->nodes['write'] = $writeNode;
$this->nodes['admin'] = $writeNode;
$this->client = $client;
$this->siteConfiguration = $siteConfiguration;
$this->configuration = $configuration ?? Util::getMeilisearchConfiguration();
$this->synonymParser = $synonymParser;
$this->stopWordParser = $stopWordParser;
@@ -160,14 +155,6 @@ class MeilisearchConnection
$this->eventDispatcher = $eventDispatcher ?? GeneralUtility::getContainer()->get(EventDispatcherInterface::class);
}
/**
* @param string $key
* @return Client
*/
public function getNode(string $key): Client
{
return $this->nodes[$key];
}
/**
* @return MeilisearchAdminService
@@ -187,9 +174,7 @@ class MeilisearchConnection
*/
protected function buildAdminService(): MeilisearchAdminService
{
$endpointKey = 'admin';
$client = $this->getClient($endpointKey);
return GeneralUtility::makeInstance(MeilisearchAdminService::class, $client, $this->configuration, $this->logger, $this->synonymParser, $this->stopWordParser, $this->schemaParser);
return GeneralUtility::makeInstance(MeilisearchAdminService::class, $this, $this->client, $this->configuration, $this->logger, $this->synonymParser, $this->stopWordParser, $this->schemaParser);
}
/**
@@ -210,9 +195,7 @@ class MeilisearchConnection
*/
protected function buildReadService(): MeilisearchReadService
{
$endpointKey = 'read';
$client = $this->getClient($endpointKey);
return GeneralUtility::makeInstance(MeilisearchReadService::class, $client);
return GeneralUtility::makeInstance(MeilisearchReadService::class, $this->client);
}
/**
@@ -233,9 +216,7 @@ class MeilisearchConnection
*/
protected function buildWriteService(): MeilisearchWriteService
{
$endpointKey = 'write';
$client = $this->getClient($endpointKey);
return GeneralUtility::makeInstance(MeilisearchWriteService::class, $client);
return GeneralUtility::makeInstance(MeilisearchWriteService::class, $this->client);
}
@@ -247,4 +228,13 @@ class MeilisearchConnection
{
$this->clients[$endpointKey] = $client;
}
/**
* @return array
*/
public function getSiteConfiguration(): array
{
return $this->siteConfiguration;
}
}