Totals.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Invoice;
  7. use Magento\Sales\Model\Order\Invoice;
  8. /**
  9. * Adminhtml order invoice totals block
  10. *
  11. * @api
  12. * @author Magento Core Team <core@magentocommerce.com>
  13. * @since 100.0.2
  14. */
  15. class Totals extends \Magento\Sales\Block\Adminhtml\Totals
  16. {
  17. /**
  18. * Order invoice
  19. *
  20. * @var Invoice|null
  21. */
  22. protected $_invoice = null;
  23. /**
  24. * Get invoice
  25. *
  26. * @return Invoice|null
  27. */
  28. public function getInvoice()
  29. {
  30. if ($this->_invoice === null) {
  31. if ($this->hasData('invoice')) {
  32. $this->_invoice = $this->_getData('invoice');
  33. } elseif ($this->_coreRegistry->registry('current_invoice')) {
  34. $this->_invoice = $this->_coreRegistry->registry('current_invoice');
  35. } elseif ($this->getParentBlock()->getInvoice()) {
  36. $this->_invoice = $this->getParentBlock()->getInvoice();
  37. }
  38. }
  39. return $this->_invoice;
  40. }
  41. /**
  42. * Get source
  43. *
  44. * @return Invoice|null
  45. */
  46. public function getSource()
  47. {
  48. return $this->getInvoice();
  49. }
  50. /**
  51. * Initialize order totals array
  52. *
  53. * @return $this
  54. */
  55. protected function _initTotals()
  56. {
  57. parent::_initTotals();
  58. return $this;
  59. }
  60. }