Items.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Sales order view items block
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Shipping\Block;
  12. /**
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Items extends \Magento\Sales\Block\Items\AbstractItems
  17. {
  18. /**
  19. * Core registry
  20. *
  21. * @var \Magento\Framework\Registry
  22. */
  23. protected $_coreRegistry = null;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Framework\Registry $registry
  27. * @param array $data
  28. */
  29. public function __construct(
  30. \Magento\Framework\View\Element\Template\Context $context,
  31. \Magento\Framework\Registry $registry,
  32. array $data = []
  33. ) {
  34. $this->_coreRegistry = $registry;
  35. parent::__construct($context, $data);
  36. }
  37. /**
  38. * Retrieve current order model instance
  39. *
  40. * @return \Magento\Sales\Model\Order
  41. */
  42. public function getOrder()
  43. {
  44. return $this->_coreRegistry->registry('current_order');
  45. }
  46. /**
  47. * @param object $shipment
  48. * @return string
  49. */
  50. public function getPrintShipmentUrl($shipment)
  51. {
  52. return $this->getUrl('*/*/printShipment', ['shipment_id' => $shipment->getId()]);
  53. }
  54. /**
  55. * @param object $order
  56. * @return string
  57. */
  58. public function getPrintAllShipmentsUrl($order)
  59. {
  60. return $this->getUrl('*/*/printShipment', ['order_id' => $order->getId()]);
  61. }
  62. /**
  63. * Get html of shipment comments block
  64. *
  65. * @param \Magento\Sales\Model\Order\Shipment $shipment
  66. * @return string
  67. */
  68. public function getCommentsHtml($shipment)
  69. {
  70. $html = '';
  71. $comments = $this->getChildBlock('shipment_comments');
  72. if ($comments) {
  73. $comments->setEntity($shipment)->setTitle(__('About Your Shipment'));
  74. $html = $comments->toHtml();
  75. }
  76. return $html;
  77. }
  78. }