Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
AdapterFactory Class Reference

Public Member Functions

 __construct (\Magento\Framework\ObjectManagerInterface $objectManager, array $adapters, EngineResolverInterface $engineResolver)
 
 create (array $data=[])
 

Protected Attributes

 $scopeConfig
 
 $objectManager
 
 $path
 
 $scope
 

Detailed Description

@api

Since
100.0.2

Definition at line 14 of file AdapterFactory.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\ObjectManagerInterface  $objectManager,
array  $adapters,
EngineResolverInterface  $engineResolver 
)
Parameters
\Magento\Framework\ObjectManagerInterface$objectManager
array$adapters
EngineResolverInterface$engineResolver

Definition at line 62 of file AdapterFactory.php.

66  {
67  $this->objectManager = $objectManager;
68  $this->adapterPool = $adapters;
69  $this->engineResolver = $engineResolver;
70  }

Member Function Documentation

◆ create()

create ( array  $data = [])

Create Adapter instance

Parameters
array$data
Returns
\Magento\Framework\Search\AdapterInterface

Definition at line 78 of file AdapterFactory.php.

79  {
80  $currentAdapter = $this->engineResolver->getCurrentSearchEngine();
81  if (!isset($this->adapterPool[$currentAdapter])) {
82  throw new \LogicException(
83  'There is no such adapter: ' . $currentAdapter
84  );
85  }
86  $adapterClass = $this->adapterPool[$currentAdapter];
87  $adapter = $this->objectManager->create($adapterClass, $data);
88  if (!($adapter instanceof \Magento\Framework\Search\AdapterInterface)) {
89  throw new \InvalidArgumentException(
90  'Adapter must implement \Magento\Framework\Search\AdapterInterface'
91  );
92  }
93  return $adapter;
94  }
$adapter
Definition: webapi_user.php:16

Field Documentation

◆ $objectManager

$objectManager
protected

Definition at line 29 of file AdapterFactory.php.

◆ $path

$path
protected

Definition at line 37 of file AdapterFactory.php.

◆ $scope

$scope
protected

Config Scope

Deprecated:
since it is not used anymore

Definition at line 43 of file AdapterFactory.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 22 of file AdapterFactory.php.


The documentation for this class was generated from the following file: