Skip to content

Commit 4b7af27

Browse files
authored
Merge pull request #1911 from magento-borg/MAGETWO-66191
Fixed issues: - MAGETWO-66191 [SWAT] remove Solr from mainline/2.3 code base as it's sunsetted functionality per messaging at Imagine 2016 (1 year sunset period for Solr)
2 parents c10eacb + c292081 commit 4b7af27

File tree

32 files changed

+956
-351
lines changed

32 files changed

+956
-351
lines changed

app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
*/
66
namespace Magento\CatalogSearch\Model\Indexer;
77

8-
use Magento\Framework\App\Config\ScopeConfigInterface;
98
use Magento\Framework\Indexer\IndexStructureInterface;
109
use Magento\Framework\ObjectManagerInterface;
11-
use Magento\Store\Model\ScopeInterface;
10+
use Magento\Framework\Search\EngineResolverInterface;
1211

1312
/**
1413
* @api
@@ -31,37 +30,26 @@ class IndexStructureFactory
3130
* @since 100.1.0
3231
*/
3332
protected $structures = null;
34-
35-
/**
36-
* @var ScopeConfigInterface
37-
*/
38-
private $scopeConfig;
39-
4033
/**
41-
* Configuration path by which current indexer handler stored
42-
*
43-
* @var string
34+
* @var EngineResolverInterface
4435
*/
45-
private $configPath;
36+
private $engineResolver;
4637

4738
/**
4839
* Factory constructor
4940
*
5041
* @param ObjectManagerInterface $objectManager
51-
* @param ScopeConfigInterface $scopeConfig
52-
* @param string $configPath
42+
* @param EngineResolverInterface $engineResolver
5343
* @param string[] $structures
5444
*/
5545
public function __construct(
5646
ObjectManagerInterface $objectManager,
57-
ScopeConfigInterface $scopeConfig,
58-
$configPath,
47+
EngineResolverInterface $engineResolver,
5948
array $structures = []
6049
) {
6150
$this->objectManager = $objectManager;
62-
$this->scopeConfig = $scopeConfig;
63-
$this->configPath = $configPath;
6451
$this->structures = $structures;
52+
$this->engineResolver = $engineResolver;
6553
}
6654

6755
/**
@@ -73,7 +61,7 @@ public function __construct(
7361
*/
7462
public function create(array $data = [])
7563
{
76-
$currentStructure = $this->scopeConfig->getValue($this->configPath, ScopeInterface::SCOPE_STORE);
64+
$currentStructure = $this->engineResolver->getCurrentSearchEngine();
7765
if (!isset($this->structures[$currentStructure])) {
7866
throw new \LogicException(
7967
'There is no such index structure: ' . $currentStructure
@@ -83,7 +71,7 @@ public function create(array $data = [])
8371

8472
if (!$indexStructure instanceof IndexStructureInterface) {
8573
throw new \InvalidArgumentException(
86-
$indexStructure . ' doesn\'t implement \Magento\Framework\Indexer\IndexStructureInterface'
74+
$currentStructure . ' index structure doesn\'t implement '. IndexStructureInterface::class
8775
);
8876
}
8977

app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherProxy.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
namespace Magento\CatalogSearch\Model\Indexer;
88

9-
use Magento\Framework\App\Config\ScopeConfigInterface;
109
use Magento\Framework\ObjectManagerInterface;
11-
use Magento\Store\Model\ScopeInterface;
10+
use Magento\Framework\Search\EngineResolverInterface;
1211

1312
/**
1413
* Proxy for adapter-specific index switcher
@@ -30,49 +29,39 @@ class IndexSwitcherProxy implements IndexSwitcherInterface
3029
private $handlers;
3130

3231
/**
33-
* @var ScopeConfigInterface
32+
* @var EngineResolverInterface
3433
*/
35-
private $scopeConfig;
36-
37-
/**
38-
* Configuration path by which current indexer handler stored
39-
*
40-
* @var string
41-
*/
42-
private $configPath;
34+
private $engineResolver;
4335

4436
/**
4537
* Factory constructor
4638
*
4739
* @param ObjectManagerInterface $objectManager
48-
* @param ScopeConfigInterface $scopeConfig
49-
* @param string $configPath
40+
* @param EngineResolverInterface $engineResolver
5041
* @param string[] $handlers
5142
*/
5243
public function __construct(
5344
ObjectManagerInterface $objectManager,
54-
ScopeConfigInterface $scopeConfig,
55-
$configPath,
45+
EngineResolverInterface $engineResolver,
5646
array $handlers = []
5747
) {
5848
$this->objectManager = $objectManager;
59-
$this->scopeConfig = $scopeConfig;
60-
$this->configPath = $configPath;
6149
$this->handlers = $handlers;
50+
$this->engineResolver = $engineResolver;
6251
}
6352

6453
/**
6554
* {@inheritDoc}
6655
*
6756
* As index switcher is an optional part of the search SPI, it may be not defined by a search engine.
68-
* It is especially reasonable for search engines with pre-defined indexes declaration (like old SOLR and Sphinx)
57+
* It is especially reasonable for search engines with pre-defined indexes declaration (like Sphinx)
6958
* which cannot create temporary indexes on the fly.
7059
* That's the reason why this method do nothing for the case
7160
* when switcher is not defined for a specific search engine.
7261
*/
7362
public function switchIndex(array $dimensions)
7463
{
75-
$currentHandler = $this->scopeConfig->getValue($this->configPath, ScopeInterface::SCOPE_STORE);
64+
$currentHandler = $this->engineResolver->getCurrentSearchEngine();
7665
if (!isset($this->handlers[$currentHandler])) {
7766
return;
7867
}

app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
*/
66
namespace Magento\CatalogSearch\Model\Indexer;
77

8-
use Magento\Framework\App\Config\ScopeConfigInterface;
98
use Magento\Framework\Indexer\SaveHandler\IndexerInterface;
109
use Magento\Framework\ObjectManagerInterface;
11-
use Magento\Store\Model\ScopeInterface;
10+
use Magento\Framework\Search\EngineResolverInterface;
1211

1312
/**
1413
* @api
@@ -31,35 +30,25 @@ class IndexerHandlerFactory
3130
protected $handlers = null;
3231

3332
/**
34-
* @var ScopeConfigInterface
33+
* @var EngineResolverInterface
3534
*/
36-
private $scopeConfig;
37-
38-
/**
39-
* Configuration path by which current indexer handler stored
40-
*
41-
* @var string
42-
*/
43-
private $configPath;
35+
private $engineResolver;
4436

4537
/**
4638
* Factory constructor
4739
*
4840
* @param ObjectManagerInterface $objectManager
49-
* @param ScopeConfigInterface $scopeConfig
50-
* @param string $configPath
41+
* @param EngineResolverInterface $engineResolver
5142
* @param string[] $handlers
5243
*/
5344
public function __construct(
5445
ObjectManagerInterface $objectManager,
55-
ScopeConfigInterface $scopeConfig,
56-
$configPath,
46+
EngineResolverInterface $engineResolver,
5747
array $handlers = []
5848
) {
5949
$this->_objectManager = $objectManager;
60-
$this->scopeConfig = $scopeConfig;
61-
$this->configPath = $configPath;
6250
$this->handlers = $handlers;
51+
$this->engineResolver = $engineResolver;
6352
}
6453

6554
/**
@@ -70,7 +59,7 @@ public function __construct(
7059
*/
7160
public function create(array $data = [])
7261
{
73-
$currentHandler = $this->scopeConfig->getValue($this->configPath, ScopeInterface::SCOPE_STORE);
62+
$currentHandler = $this->engineResolver->getCurrentSearchEngine();
7463
if (!isset($this->handlers[$currentHandler])) {
7564
throw new \LogicException(
7665
'There is no such indexer handler: ' . $currentHandler

app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ interface EngineInterface
1919

2020
/**
2121
* Scope identifier
22+
*
23+
* @deprecated since using engine resolver
24+
* @see \Magento\Framework\Search\EngineResolverInterface
2225
*/
2326
const SCOPE_IDENTIFIER = 'scope';
2427

2528
/**
2629
* Configuration path by which current indexer handler stored
30+
*
31+
* @deprecated since using engine resolver
32+
* @see \Magento\Framework\Search\EngineResolverInterface
2733
*/
2834
const CONFIG_ENGINE_PATH = 'catalog/search/engine';
2935

app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@
99
*/
1010
namespace Magento\CatalogSearch\Model\ResourceModel;
1111

12-
use Magento\Store\Model\ScopeInterface;
12+
use Magento\CatalogSearch\Model\ResourceModel\EngineInterface;
13+
use Magento\Framework\Search\EngineResolverInterface;
1314

1415
/**
1516
* @api
1617
* @since 100.0.2
1718
*/
1819
class EngineProvider
1920
{
21+
/**
22+
* @deprecated since using engine resolver
23+
* @see \Magento\Framework\Search\EngineResolverInterface
24+
*/
2025
const CONFIG_ENGINE_PATH = 'catalog/search/engine';
2126

2227
/**
23-
* @var \Magento\CatalogSearch\Model\ResourceModel\EngineInterface
28+
* @var EngineInterface
2429
*/
2530
protected $engine;
2631

2732
/**
2833
* @var \Magento\Framework\App\Config\ScopeConfigInterface
34+
* @deprecated since it is not used anymore
2935
*/
3036
protected $scopeConfig;
3137

@@ -42,18 +48,23 @@ class EngineProvider
4248
private $enginePool;
4349

4450
/**
45-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
51+
* @var EngineResolverInterface
52+
*/
53+
private $engineResolver;
54+
55+
/**
4656
* @param \Magento\Framework\ObjectManagerInterface $objectManager
4757
* @param array $engines
58+
* @param EngineResolverInterface $engineResolver
4859
*/
4960
public function __construct(
50-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
5161
\Magento\Framework\ObjectManagerInterface $objectManager,
52-
array $engines
62+
array $engines,
63+
EngineResolverInterface $engineResolver
5364
) {
54-
$this->scopeConfig = $scopeConfig;
5565
$this->objectManager = $objectManager;
5666
$this->enginePool = $engines;
67+
$this->engineResolver = $engineResolver;
5768
}
5869

5970
/**
@@ -64,7 +75,7 @@ public function __construct(
6475
public function get()
6576
{
6677
if (!$this->engine) {
67-
$currentEngine = $this->scopeConfig->getValue(self::CONFIG_ENGINE_PATH, ScopeInterface::SCOPE_STORE);
78+
$currentEngine = $this->engineResolver->getCurrentSearchEngine();
6879
if (!isset($this->enginePool[$currentEngine])) {
6980
throw new \LogicException(
7081
'There is no such engine: ' . $currentEngine
@@ -73,12 +84,13 @@ public function get()
7384
$engineClassName = $this->enginePool[$currentEngine];
7485

7586
$engine = $this->objectManager->create($engineClassName);
76-
if (false === $engine instanceof \Magento\CatalogSearch\Model\ResourceModel\EngineInterface) {
87+
if (false === $engine instanceof EngineInterface) {
7788
throw new \LogicException(
78-
$engineClassName . ' doesn\'t implement \Magento\CatalogSearch\Model\ResourceModel\EngineInterface'
89+
$currentEngine . ' doesn\'t implement ' . EngineInterface::class
7990
);
8091
}
8192

93+
/** @var $engine EngineInterface */
8294
if ($engine && !$engine->isAvailable()) {
8395
throw new \LogicException(
8496
'Engine is not available: ' . $currentEngine

0 commit comments

Comments
 (0)