BatchUrl.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\ViewModel\DataProvider;
  6. use Magento\Framework\UrlInterface;
  7. use Temando\Shipping\Model\BatchInterface;
  8. /**
  9. * Batch URL provider
  10. *
  11. * @package Temando\Shipping\ViewModel
  12. * @author Rhodri Davies <rhodri.davies@temando.com>
  13. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  14. * @link http://www.temando.com/
  15. */
  16. class BatchUrl implements EntityUrlInterface
  17. {
  18. /**
  19. * Url Builder
  20. *
  21. * @var UrlInterface
  22. */
  23. private $urlBuilder;
  24. /**
  25. * BatchUrl constructor.
  26. * @param UrlInterface $urlBuilder
  27. */
  28. public function __construct(UrlInterface $urlBuilder)
  29. {
  30. $this->urlBuilder = $urlBuilder;
  31. }
  32. /**
  33. * @return string
  34. */
  35. public function getNewActionUrl(): string
  36. {
  37. return $this->urlBuilder->getUrl('temando/batch/create');
  38. }
  39. /**
  40. * @return string
  41. */
  42. public function getListActionUrl(): string
  43. {
  44. return $this->urlBuilder->getUrl('temando/batch/index');
  45. }
  46. /**
  47. * @param mixed[] $data Item data to pick entity identifier.
  48. * @return string
  49. */
  50. public function getViewActionUrl(array $data): string
  51. {
  52. return $this->urlBuilder->getUrl('temando/batch/view', [
  53. BatchInterface::BATCH_ID => $data[BatchInterface::BATCH_ID],
  54. ]);
  55. }
  56. /**
  57. * @param mixed[] $data Item data to pick entity identifier.
  58. * @return string
  59. */
  60. public function getEditActionUrl(array $data): string
  61. {
  62. return '';
  63. }
  64. /**
  65. * @param mixed[] $data Item data for the implementer to pick entity identifier.
  66. * @return string
  67. */
  68. public function getDeleteActionUrl(array $data): string
  69. {
  70. return '';
  71. }
  72. /**
  73. * @param mixed[] $data Item data to pick entity identifier.
  74. * @return string
  75. */
  76. public function getSolveActionUrl(array $data): string
  77. {
  78. return $this->urlBuilder->getUrl('temando/batch/solve', [
  79. BatchInterface::BATCH_ID => $data[BatchInterface::BATCH_ID],
  80. ]);
  81. }
  82. /**
  83. * @param mixed[] $data
  84. * @param string $batchId
  85. * @return string
  86. */
  87. public function getPrintAllPackingSlips(array $data, string $batchId): string
  88. {
  89. $ids = implode(",", $data);
  90. return $this->urlBuilder->getUrl(
  91. 'temando/batch/printpackageslips',
  92. ['order_ids' => $ids, 'batch_id' => $batchId]
  93. );
  94. }
  95. }