PickupUrl.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\ViewModel\Pickup;
  6. use Magento\Framework\View\Element\Block\ArgumentInterface;
  7. use Temando\Shipping\ViewModel\DataProvider\PickupUrl as UrlProvider;
  8. /**
  9. * View model for Pickup Action URLs.
  10. *
  11. * Wrapper around the pickup URL provider, usable as block argument.
  12. *
  13. * @package Temando\Shipping\ViewModel
  14. * @author Sebastian Ertner<sebastian.ertner@netresearch.de>
  15. * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  16. * @link https://www.temando.com/
  17. */
  18. class PickupUrl implements ArgumentInterface
  19. {
  20. /**
  21. * @var UrlProvider
  22. */
  23. private $urlProvider;
  24. /**
  25. * PickupUrl constructor.
  26. * @param UrlProvider $urlProvider
  27. */
  28. public function __construct(UrlProvider $urlProvider)
  29. {
  30. $this->urlProvider = $urlProvider;
  31. }
  32. /**
  33. * Creating pickup fulfillments via UI is not supported.
  34. *
  35. * @return string
  36. */
  37. public function getNewActionUrl(): string
  38. {
  39. return $this->urlProvider->getNewActionUrl();
  40. }
  41. /**
  42. * Link to the pickup fulfillment grid listing.
  43. *
  44. * @return string
  45. */
  46. public function getListActionUrl(): string
  47. {
  48. return $this->urlProvider->getListActionUrl();
  49. }
  50. /**
  51. * Link to the pickup detail view. Applies to the following pickup states:
  52. * - ready for pickup
  53. * - picked up
  54. * - cancelled
  55. *
  56. * @param mixed[] $data Item data for the implementer to pick entity identifier.
  57. * @return string
  58. */
  59. public function getViewActionUrl(array $data): string
  60. {
  61. return $this->urlProvider->getViewActionUrl($data);
  62. }
  63. /**
  64. * @return string
  65. */
  66. public function getForwardActionUrl(): string
  67. {
  68. return $this->urlProvider->getForwardActionUrl();
  69. }
  70. /**
  71. * Link to the "Prepare for Pickup" page with editable quantities.
  72. *
  73. * @param mixed[] $data Item data for the implementer to pick entity identifier.
  74. * @return string
  75. */
  76. public function getEditActionUrl(array $data): string
  77. {
  78. return $this->urlProvider->getEditActionUrl($data);
  79. }
  80. /**
  81. * Link to the pickup cancel POST action.
  82. *
  83. * @param mixed[] $data Item data for the implementer to pick entity identifier.
  84. * @return string
  85. */
  86. public function getDeleteActionUrl(array $data): string
  87. {
  88. return $this->urlProvider->getDeleteActionUrl($data);
  89. }
  90. /**
  91. * Link to the "mark as ready for pickup" POST action
  92. *
  93. * @param mixed[] $data Item data to pick entity identifiers.
  94. * @return string
  95. */
  96. public function getReadyActionUrl(array $data): string
  97. {
  98. return $this->urlProvider->getReadyActionUrl($data);
  99. }
  100. /**
  101. * Link to the "mark as picked up" POST action
  102. *
  103. * @param mixed[] $data Item data for the implementer to pick entity identifier.
  104. * @return string
  105. */
  106. public function getCollectedActionUrl(array $data): string
  107. {
  108. return $this->urlProvider->getCollectedActionUrl($data);
  109. }
  110. }