Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
ItemPool Class Reference
Inheritance diagram for ItemPool:
ItemPoolInterface

Public Member Functions

 __construct (ObjectManagerInterface $objectManager, $defaultItemId, array $itemMap=[])
 
 getItemData (Item $item)
 

Protected Member Functions

 get ($type)
 

Protected Attributes

 $objectManager
 
 $defaultItemId
 
 $itemMap
 

Detailed Description

Item pool

Definition at line 16 of file ItemPool.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ObjectManagerInterface  $objectManager,
  $defaultItemId,
array  $itemMap = [] 
)

Construct

Parameters
ObjectManagerInterface$objectManager
string$defaultItemId
array$itemMap@codeCoverageIgnore

Definition at line 47 of file ItemPool.php.

51  {
52  $this->objectManager = $objectManager;
53  $this->defaultItemId = $defaultItemId;
54  $this->itemMap = $itemMap;
55  }

Member Function Documentation

◆ get()

get (   $type)
protected

Get section source by name

Parameters
string$type
Returns
ItemInterface
Exceptions
LocalizedException

Definition at line 73 of file ItemPool.php.

74  {
75  $itemId = isset($this->itemMap[$type]) ? $this->itemMap[$type] : $this->defaultItemId;
76  $item = $this->objectManager->get($itemId);
77 
78  if (!$item instanceof ItemInterface) {
79  throw new LocalizedException(
80  __('%1 doesn\'t extend \Magento\Checkout\CustomerData\ItemInterface', $type)
81  );
82  }
83  return $item;
84  }
__()
Definition: __.php:13
$type
Definition: item.phtml:13

◆ getItemData()

getItemData ( Item  $item)

{Get item data by quote item

Parameters
Item$item
Returns
array
} @codeCoverageIgnore

Implements ItemPoolInterface.

Definition at line 61 of file ItemPool.php.

62  {
63  return $this->get($item->getProductType())->getItemData($item);
64  }

Field Documentation

◆ $defaultItemId

$defaultItemId
protected

Definition at line 30 of file ItemPool.php.

◆ $itemMap

$itemMap
protected

Definition at line 37 of file ItemPool.php.

◆ $objectManager

$objectManager
protected

Definition at line 23 of file ItemPool.php.


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