configBuilder = $configBuilder; $this->objectManager = $objectManager; $this->engines = $engines; } /** * @throws NotAmastySearchEngine */ public function create(string $searchEngine, array $options): ClientInterface { if (!isset($this->engines[$searchEngine])) { throw new NotAmastySearchEngine(__('Selected engine not supported by Amasty_Elasticsearch module.')); } /** @var ClientInterface $client */ $client = $this->objectManager->create($this->engines[$searchEngine], [ 'options' => $this->configBuilder->build($searchEngine, $options) ]); return $client; } }