Tabs.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\View;
  7. /**
  8. * Order view tabs
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Tabs extends \Magento\Backend\Block\Widget\Tabs
  14. {
  15. /**
  16. * Core registry
  17. *
  18. * @var \Magento\Framework\Registry
  19. */
  20. protected $_coreRegistry = null;
  21. /**
  22. * @param \Magento\Backend\Block\Template\Context $context
  23. * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
  24. * @param \Magento\Backend\Model\Auth\Session $authSession
  25. * @param \Magento\Framework\Registry $registry
  26. * @param array $data
  27. */
  28. public function __construct(
  29. \Magento\Backend\Block\Template\Context $context,
  30. \Magento\Framework\Json\EncoderInterface $jsonEncoder,
  31. \Magento\Backend\Model\Auth\Session $authSession,
  32. \Magento\Framework\Registry $registry,
  33. array $data = []
  34. ) {
  35. $this->_coreRegistry = $registry;
  36. parent::__construct($context, $jsonEncoder, $authSession, $data);
  37. }
  38. /**
  39. * Retrieve available order
  40. *
  41. * @return \Magento\Sales\Model\Order
  42. * @throws \Magento\Framework\Exception\LocalizedException
  43. */
  44. public function getOrder()
  45. {
  46. if ($this->hasOrder()) {
  47. return $this->getData('order');
  48. }
  49. if ($this->_coreRegistry->registry('current_order')) {
  50. return $this->_coreRegistry->registry('current_order');
  51. }
  52. if ($this->_coreRegistry->registry('order')) {
  53. return $this->_coreRegistry->registry('order');
  54. }
  55. throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t get the order instance right now.'));
  56. }
  57. /**
  58. * Constructor
  59. *
  60. * @return void
  61. */
  62. protected function _construct()
  63. {
  64. parent::_construct();
  65. $this->setId('sales_order_view_tabs');
  66. $this->setDestElementId('sales_order_view');
  67. $this->setTitle(__('Order View'));
  68. }
  69. }