Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EngineResolver.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Search\Model;
7 
10 use Psr\Log\LoggerInterface;
11 
17 {
21  const CATALOG_SEARCH_MYSQL_ENGINE = 'mysql';
22 
27  protected $scopeConfig;
28 
34  protected $path;
35 
41  protected $scopeType;
42 
48  protected $scopeCode;
49 
54  private $engines = [];
55 
59  private $logger;
60 
68  public function __construct(
70  array $engines,
71  LoggerInterface $logger,
72  $path,
73  $scopeType,
74  $scopeCode = null
75  ) {
76  $this->scopeConfig = $scopeConfig;
77  $this->path = $path;
78  $this->scopeType = $scopeType;
79  $this->scopeCode = $scopeCode;
80  $this->engines = $engines;
81  $this->logger = $logger;
82  }
83 
92  public function getCurrentSearchEngine()
93  {
94  $engine = $this->scopeConfig->getValue(
95  $this->path,
96  $this->scopeType,
97  $this->scopeCode
98  );
99 
100  if (in_array($engine, $this->engines)) {
101  return $engine;
102  } else {
103  $this->logger->error(
104  $engine . ' search engine doesn\'t exists. Falling back to ' . self::CATALOG_SEARCH_MYSQL_ENGINE
105  );
107  }
108  }
109 }
$logger
__construct(ScopeConfigInterface $scopeConfig, array $engines, LoggerInterface $logger, $path, $scopeType, $scopeCode=null)