8 use \Magento\Framework\ObjectManagerInterface;
39 private $clientFactoryPool;
46 private $clientOptionsPool;
51 private $engineResolver;
77 array $clientFactories,
82 $this->clientFactoryPool = $clientFactories;
83 $this->clientOptionsPool = $clientOptions;
84 $this->engineResolver = $engineResolver;
95 return $this->engineResolver->getCurrentSearchEngine();
110 if (!isset($this->clientFactoryPool[$engine])) {
111 throw new \LogicException(
112 'There is no such client factory: ' . $engine
115 $factoryClass = $this->clientFactoryPool[$engine];
116 $factory = $this->objectManager->create($factoryClass);
118 throw new \InvalidArgumentException(
119 'Client factory must implement \Magento\AdvancedSearch\Model\Client\ClientFactoryInterface' 123 $optionsClass = $this->clientOptionsPool[$engine];
124 $clientOptions = $this->objectManager->create($optionsClass);
126 throw new \InvalidArgumentException(
127 'Client options must implement \Magento\AdvancedSearch\Model\Client\ClientInterface' 131 $client =
$factory->create($clientOptions->prepareClientOptions(
$data));
create($engine='', array $data=[])
__construct(ObjectManagerInterface $objectManager, array $clientFactories, array $clientOptions, EngineResolverInterface $engineResolver)