Container.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Order\History;
  7. /**
  8. * Sales order history extra container block
  9. *
  10. * @api
  11. * @since 100.1.1
  12. */
  13. class Container extends \Magento\Framework\View\Element\Template
  14. {
  15. /**
  16. * @var \Magento\Sales\Api\Data\OrderInterface
  17. */
  18. private $order;
  19. /**
  20. * Set order
  21. *
  22. * @param \Magento\Sales\Api\Data\OrderInterface $order
  23. * @return $this
  24. * @since 100.1.1
  25. */
  26. public function setOrder(\Magento\Sales\Api\Data\OrderInterface $order)
  27. {
  28. $this->order = $order;
  29. return $this;
  30. }
  31. /**
  32. * Get order
  33. *
  34. * @return \Magento\Sales\Api\Data\OrderInterface
  35. */
  36. private function getOrder()
  37. {
  38. return $this->order;
  39. }
  40. /**
  41. * Here we set an order for children during retrieving their HTML
  42. *
  43. * @param string $alias
  44. * @param bool $useCache
  45. * @return string
  46. * @throws \Magento\Framework\Exception\LocalizedException
  47. * @since 100.1.1
  48. */
  49. public function getChildHtml($alias = '', $useCache = false)
  50. {
  51. $layout = $this->getLayout();
  52. if ($layout) {
  53. $name = $this->getNameInLayout();
  54. foreach ($layout->getChildBlocks($name) as $child) {
  55. $child->setOrder($this->getOrder());
  56. }
  57. }
  58. return parent::getChildHtml($alias, $useCache);
  59. }
  60. }