Create.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Shipping\Block\Adminhtml;
  7. /**
  8. * Adminhtml shipment create
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Create extends \Magento\Backend\Block\Widget\Form\Container
  14. {
  15. /**
  16. * Core registry
  17. *
  18. * @var \Magento\Framework\Registry
  19. */
  20. protected $_coreRegistry = null;
  21. /**
  22. * @param \Magento\Backend\Block\Widget\Context $context
  23. * @param \Magento\Framework\Registry $registry
  24. * @param array $data
  25. */
  26. public function __construct(
  27. \Magento\Backend\Block\Widget\Context $context,
  28. \Magento\Framework\Registry $registry,
  29. array $data = []
  30. ) {
  31. $this->_coreRegistry = $registry;
  32. parent::__construct($context, $data);
  33. }
  34. /**
  35. * @return void
  36. */
  37. protected function _construct()
  38. {
  39. $this->_objectId = 'order_id';
  40. $this->_mode = 'create';
  41. parent::_construct();
  42. $this->buttonList->remove('save');
  43. $this->buttonList->remove('delete');
  44. }
  45. /**
  46. * Retrieve shipment model instance
  47. *
  48. * @return \Magento\Sales\Model\Order\Shipment
  49. */
  50. public function getShipment()
  51. {
  52. return $this->_coreRegistry->registry('current_shipment');
  53. }
  54. /**
  55. * @return string
  56. */
  57. public function getHeaderText()
  58. {
  59. $header = __('New Shipment for Order #%1', $this->getShipment()->getOrder()->getRealOrderId());
  60. return $header;
  61. }
  62. /**
  63. * @return string
  64. */
  65. public function getBackUrl()
  66. {
  67. return $this->getUrl(
  68. 'sales/order/view',
  69. ['order_id' => $this->getShipment() ? $this->getShipment()->getOrderId() : null]
  70. );
  71. }
  72. }