Actions.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Block\Cart\Item\Renderer;
  7. use Magento\Checkout\Block\Cart\Item\Renderer\Actions\Generic;
  8. use Magento\Framework\View\Element\Text;
  9. use Magento\Quote\Model\Quote\Item\AbstractItem;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Actions extends Text
  15. {
  16. /**
  17. * @var AbstractItem
  18. */
  19. protected $item;
  20. /**
  21. * Returns current quote item
  22. *
  23. * @return AbstractItem
  24. * @codeCoverageIgnore
  25. */
  26. public function getItem()
  27. {
  28. return $this->item;
  29. }
  30. /**
  31. * Set current quote item
  32. *
  33. * @param AbstractItem $item
  34. * @return $this
  35. * @codeCoverageIgnore
  36. */
  37. public function setItem(AbstractItem $item)
  38. {
  39. $this->item = $item;
  40. return $this;
  41. }
  42. /**
  43. * Render html output
  44. *
  45. * @return string
  46. */
  47. protected function _toHtml()
  48. {
  49. $this->setText('');
  50. $layout = $this->getLayout();
  51. foreach ($this->getChildNames() as $child) {
  52. /** @var Generic $childBlock */
  53. $childBlock = $layout->getBlock($child);
  54. if ($childBlock instanceof Generic) {
  55. $childBlock->setItem($this->getItem());
  56. $this->addText($layout->renderElement($child, false));
  57. }
  58. }
  59. return parent::_toHtml();
  60. }
  61. }