Address.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order;
  7. /**
  8. * Edit order address form container block
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Address 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. * Constructor
  36. *
  37. * @return void
  38. */
  39. protected function _construct()
  40. {
  41. $this->_controller = 'adminhtml_order';
  42. $this->_mode = 'address';
  43. $this->_blockGroup = 'Magento_Sales';
  44. parent::_construct();
  45. $this->buttonList->update('save', 'label', __('Save Order Address'));
  46. $this->buttonList->remove('delete');
  47. }
  48. /**
  49. * Retrieve text for header element depending on loaded page
  50. *
  51. * @return \Magento\Framework\Phrase
  52. */
  53. public function getHeaderText()
  54. {
  55. $address = $this->_coreRegistry->registry('order_address');
  56. $orderId = $address->getOrder()->getIncrementId();
  57. if ($address->getAddressType() == 'shipping') {
  58. $type = __('Shipping');
  59. } else {
  60. $type = __('Billing');
  61. }
  62. return __('Edit Order %1 %2 Address', $orderId, $type);
  63. }
  64. /**
  65. * Back button url getter
  66. *
  67. * @return string
  68. */
  69. public function getBackUrl()
  70. {
  71. $address = $this->_coreRegistry->registry('order_address');
  72. return $this->getUrl('sales/*/view', ['order_id' => $address ? $address->getOrder()->getId() : null]);
  73. }
  74. }