RmaView.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\ViewModel\Rma;
  6. use Magento\Framework\View\Element\Block\ArgumentInterface;
  7. use Magento\Rma\Api\Data\RmaInterface;
  8. use Magento\Sales\Api\Data\OrderInterface;
  9. use Temando\Shipping\Model\ResourceModel\Rma\RmaAccess;
  10. use Temando\Shipping\Model\ShipmentInterface;
  11. use Temando\Shipping\ViewModel\RmaAccessInterface;
  12. /**
  13. * View model for RMA related blocks.
  14. *
  15. * @package Temando\Shipping\ViewModel
  16. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  17. * @author Sebastian Ertner<sebastian.ertner@netresearch.de>
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. * @link http://www.temando.com/
  20. */
  21. class RmaView implements ArgumentInterface, RmaAccessInterface
  22. {
  23. /**
  24. * @var RmaAccess
  25. */
  26. private $rmaAccess;
  27. /**
  28. * RmaView constructor.
  29. * @param RmaAccess $rmaAccess
  30. */
  31. public function __construct(RmaAccess $rmaAccess)
  32. {
  33. $this->rmaAccess = $rmaAccess;
  34. }
  35. /**
  36. * @return OrderInterface
  37. */
  38. public function getOrder(): OrderInterface
  39. {
  40. /** @var \Magento\Rma\Model\Rma $rma */
  41. $rma = $this->getRma();
  42. return $rma->getOrder();
  43. }
  44. /**
  45. * @return RmaInterface
  46. */
  47. public function getRma(): RmaInterface
  48. {
  49. return $this->rmaAccess->getCurrentRma();
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getReturnShipmentId()
  55. {
  56. $returnShipment = $this->rmaAccess->getCurrentRmaShipment();
  57. if (!$returnShipment) {
  58. return '';
  59. }
  60. return $returnShipment->getShipmentId();
  61. }
  62. /**
  63. * @deprecated since 1.2.0 | no longer available
  64. * @return ShipmentInterface
  65. */
  66. public function getRmaShipment(): ShipmentInterface
  67. {
  68. return $this->rmaAccess->getCurrentRmaShipment();
  69. }
  70. }