objectManager = $objectManager; $this->defaultItemId = $defaultItemId; $this->itemMap = $itemMap; } /** * {@inheritdoc} * @codeCoverageIgnore */ public function getItemData(Item $item) { return $this->get($item->getProductType())->getItemData($item); } /** * Get section source by name * * @param string $type * @return ItemInterface * @throws LocalizedException */ protected function get($type) { $itemId = isset($this->itemMap[$type]) ? $this->itemMap[$type] : $this->defaultItemId; $item = $this->objectManager->get($itemId); if (!$item instanceof ItemInterface) { throw new LocalizedException( __('%1 doesn\'t extend \Magento\Checkout\CustomerData\ItemInterface', $type) ); } return $item; } }