Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-elasticsearch
SearchAdapter
ConnectionManager.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Elasticsearch\SearchAdapter
;
7
8
use
Magento\AdvancedSearch\Model\Client\ClientOptionsInterface
;
9
use
Magento\AdvancedSearch\Model\Client\ClientFactoryInterface
;
10
use
Magento\Elasticsearch\Model\Client\Elasticsearch
;
11
use Psr\Log\LoggerInterface;
12
17
class
ConnectionManager
18
{
23
protected
$client
;
24
29
protected
$logger
;
30
35
protected
$clientFactory
;
36
41
protected
$clientConfig
;
42
48
public
function
__construct
(
49
ClientFactoryInterface
$clientFactory
,
50
ClientOptionsInterface
$clientConfig
,
51
LoggerInterface
$logger
52
) {
53
$this->logger =
$logger
;
54
$this->clientFactory =
$clientFactory
;
55
$this->clientConfig =
$clientConfig
;
56
}
57
66
public
function
getConnection
(
$options
= [])
67
{
68
if
(!$this->client) {
69
$this->connect(
$options
);
70
}
71
72
return
$this->client
;
73
}
74
82
private
function
connect(
$options
)
83
{
84
try
{
85
$this->client = $this->clientFactory->create($this->clientConfig->prepareClientOptions(
$options
));
86
}
catch
(\Exception $e) {
87
$this->logger->critical($e);
88
throw
new \RuntimeException(
'Elasticsearch client is not set.'
);
89
}
90
}
91
}
Magento\Elasticsearch\SearchAdapter\ConnectionManager\$clientConfig
$clientConfig
Definition:
ConnectionManager.php:41
Magento\Elasticsearch\SearchAdapter\ConnectionManager\$client
$client
Definition:
ConnectionManager.php:23
Magento\AdvancedSearch\Model\Client\ClientFactoryInterface
Definition:
ClientFactoryInterface.php:12
Magento\Elasticsearch\SearchAdapter\ConnectionManager\getConnection
getConnection($options=[])
Definition:
ConnectionManager.php:66
Magento\Elasticsearch\SearchAdapter\ConnectionManager\__construct
__construct(ClientFactoryInterface $clientFactory, ClientOptionsInterface $clientConfig, LoggerInterface $logger)
Definition:
ConnectionManager.php:48
Magento\Elasticsearch\Model\Client\Elasticsearch
Definition:
Elasticsearch.php:15
Magento\Elasticsearch\SearchAdapter\ConnectionManager\$logger
$logger
Definition:
ConnectionManager.php:29
Magento\Elasticsearch\SearchAdapter
Definition:
AdapterTest.php:6
Magento\Elasticsearch\SearchAdapter\ConnectionManager
Definition:
ConnectionManager.php:17
Magento\AdvancedSearch\Model\Client\ClientOptionsInterface
Definition:
ClientOptionsInterface.php:12
$options
$options
Definition:
multiple_mixed_products.php:29
Magento\Elasticsearch\SearchAdapter\ConnectionManager\$clientFactory
$clientFactory
Definition:
ConnectionManager.php:35