Transactions.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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\Tab;
  7. /**
  8. * Order transactions tab
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Transactions extends \Magento\Framework\View\Element\Text\ListText implements
  14. \Magento\Backend\Block\Widget\Tab\TabInterface
  15. {
  16. /**
  17. * @var \Magento\Framework\AuthorizationInterface
  18. */
  19. protected $_authorization;
  20. /**
  21. * Core registry
  22. *
  23. * @var \Magento\Framework\Registry
  24. */
  25. protected $_coreRegistry = null;
  26. /**
  27. * @param \Magento\Framework\View\Element\Context $context
  28. * @param \Magento\Framework\AuthorizationInterface $authorization
  29. * @param \Magento\Framework\Registry $registry
  30. * @param array $data
  31. */
  32. public function __construct(
  33. \Magento\Framework\View\Element\Context $context,
  34. \Magento\Framework\AuthorizationInterface $authorization,
  35. \Magento\Framework\Registry $registry,
  36. array $data = []
  37. ) {
  38. $this->_authorization = $authorization;
  39. $this->_coreRegistry = $registry;
  40. parent::__construct($context, $data);
  41. }
  42. /**
  43. * Retrieve order model instance
  44. *
  45. * @return \Magento\Sales\Model\Order
  46. */
  47. public function getOrder()
  48. {
  49. return $this->_coreRegistry->registry('current_order');
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function getTabLabel()
  55. {
  56. return __('Transactions');
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function getTabTitle()
  62. {
  63. return __('Transactions');
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function canShowTab()
  69. {
  70. return !$this->getOrder()->getPayment()->getMethodInstance()->isOffline();
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function isHidden()
  76. {
  77. return !$this->_authorization->isAllowed('Magento_Sales::transactions_fetch');
  78. }
  79. }