Example #1
0
 /**
  * @param Filesystem             $fs
  * @param Config                 $config
  * @param Helper                 $helper
  * @param IndexCollectionFactory $indexCollectionFactory
  * @param StoreManagerInterface  $storeManager
  */
 public function __construct(Filesystem $fs, Config $config, Helper $helper, IndexCollectionFactory $indexCollectionFactory, StoreManagerInterface $storeManager)
 {
     $this->config = $config;
     $this->helper = $helper;
     $this->indexCollectionFactory = $indexCollectionFactory;
     $this->storeManager = $storeManager;
     $this->directory = $fs->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->basePath = $fs->getDirectoryRead(DirectoryList::VAR_DIR)->getRelativePath('sphinx');
     $this->configFilePath = $this->basePath . DIRECTORY_SEPARATOR . 'sphinx.conf';
     $this->absConfigFilePath = $this->directory->getAbsolutePath($this->configFilePath);
     $this->host = $this->config->getHost();
     $this->port = $this->config->getPort();
     // check all paths
     foreach ($this->config->getBinPath() as $binPath) {
         $this->searchdCommand = $binPath;
         if ($this->isAvailable()) {
             break;
         }
     }
     $this->connection = new \Mirasvit\SearchSphinx\SphinxQL\Connection();
     $this->connection->setParams(['host' => $this->host, 'port' => $this->port]);
     if (file_exists($this->absConfigFilePath . '.attr')) {
         $this->availableAttributes = json_decode(file_get_contents($this->absConfigFilePath . '.attr'), true);
     }
 }