Renderer.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Shopping cart downloadable item render block
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Downloadable\Block\Checkout\Cart\Item;
  12. use Magento\Framework\Pricing\PriceCurrencyInterface;
  13. use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
  14. /**
  15. * @api
  16. * @since 100.0.2
  17. */
  18. class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
  19. {
  20. /**
  21. * Downloadable catalog product configuration
  22. *
  23. * @var \Magento\Downloadable\Helper\Catalog\Product\Configuration
  24. */
  25. protected $_downloadableProductConfiguration = null;
  26. /**
  27. * @param \Magento\Framework\View\Element\Template\Context $context
  28. * @param \Magento\Catalog\Helper\Product\Configuration $productConfig
  29. * @param \Magento\Checkout\Model\Session $checkoutSession
  30. * @param \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder
  31. * @param \Magento\Framework\Url\Helper\Data $urlHelper
  32. * @param \Magento\Framework\Message\ManagerInterface $messageManager
  33. * @param PriceCurrencyInterface $priceCurrency
  34. * @param \Magento\Framework\Module\Manager $moduleManager
  35. * @param InterpretationStrategyInterface $messageInterpretationStrategy
  36. * @param \Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration
  37. * @param array $data
  38. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  39. */
  40. public function __construct(
  41. \Magento\Framework\View\Element\Template\Context $context,
  42. \Magento\Catalog\Helper\Product\Configuration $productConfig,
  43. \Magento\Checkout\Model\Session $checkoutSession,
  44. \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder,
  45. \Magento\Framework\Url\Helper\Data $urlHelper,
  46. \Magento\Framework\Message\ManagerInterface $messageManager,
  47. PriceCurrencyInterface $priceCurrency,
  48. \Magento\Framework\Module\Manager $moduleManager,
  49. InterpretationStrategyInterface $messageInterpretationStrategy,
  50. \Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration,
  51. array $data = []
  52. ) {
  53. $this->_downloadableProductConfiguration = $downloadableProductConfiguration;
  54. parent::__construct(
  55. $context,
  56. $productConfig,
  57. $checkoutSession,
  58. $imageBuilder,
  59. $urlHelper,
  60. $messageManager,
  61. $priceCurrency,
  62. $moduleManager,
  63. $messageInterpretationStrategy,
  64. $data
  65. );
  66. }
  67. /**
  68. * Retrieves item links options
  69. *
  70. * @return array
  71. */
  72. public function getLinks()
  73. {
  74. if (!$this->getItem()) {
  75. return [];
  76. }
  77. return $this->_downloadableProductConfiguration->getLinks($this->getItem());
  78. }
  79. /**
  80. * Return title of links section
  81. *
  82. * @return string
  83. */
  84. public function getLinksTitle()
  85. {
  86. return $this->_downloadableProductConfiguration->getLinksTitle($this->getProduct());
  87. }
  88. /**
  89. * Get list of all options for product
  90. *
  91. * @return array
  92. */
  93. public function getOptionList()
  94. {
  95. return $this->_downloadableProductConfiguration->getOptions($this->getItem());
  96. }
  97. /**
  98. * Get list of all options for product
  99. * @param \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item
  100. * @return array
  101. */
  102. public function getOption($item)
  103. {
  104. return $this->_downloadableProductConfiguration->getOptions($item);
  105. }
  106. }