Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataMapperResolver.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  private $dataMapperEntity;
22 
26  private $dataMapperFactory;
27 
31  public function __construct(DataMapperFactory $dataMapperFactory)
32  {
33  $this->dataMapperFactory = $dataMapperFactory;
34  }
35 
39  public function map(array $documentData, $storeId, array $context = [])
40  {
41  $entityType = isset($context['entityType']) ? $context['entityType'] : Config::ELASTICSEARCH_TYPE_DEFAULT;
42  return $this->getDataMapper($entityType)->map($documentData, $storeId, $context);
43  }
44 
53  private function getDataMapper($entityType)
54  {
55  if (!isset($this->dataMapperEntity[$entityType])) {
56  $this->dataMapperEntity[$entityType] = $this->dataMapperFactory->create($entityType);
57  }
58 
59  return $this->dataMapperEntity[$entityType];
60  }
61 }