CarrierUrl.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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\CarrierInterface;
  8. /**
  9. * Carrier URL provider
  10. *
  11. * @package Temando\Shipping\ViewModel
  12. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  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 CarrierUrl implements EntityUrlInterface
  17. {
  18. /**
  19. * Url Builder
  20. *
  21. * @var UrlInterface
  22. */
  23. private $urlBuilder;
  24. /**
  25. * CarrierUrl 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/configuration_carrier/new');
  38. }
  39. /**
  40. * @return string
  41. */
  42. public function getListActionUrl(): string
  43. {
  44. return $this->urlBuilder->getUrl('temando/configuration_carrier/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 '';
  53. }
  54. /**
  55. * @param mixed[] $data Item data to pick entity identifier.
  56. * @return string
  57. */
  58. public function getEditActionUrl(array $data): string
  59. {
  60. return $this->urlBuilder->getUrl('temando/configuration_carrier/edit', [
  61. CarrierInterface::CONFIGURATION_ID => $data[CarrierInterface::CONFIGURATION_ID],
  62. CarrierInterface::INTEGRATION_ID => $data[CarrierInterface::INTEGRATION_ID]
  63. ]);
  64. }
  65. /**
  66. * @param mixed[] $data Item data for the implementer to pick entity identifier.
  67. * @return string
  68. */
  69. public function getDeleteActionUrl(array $data): string
  70. {
  71. return $this->urlBuilder->getUrl('temando/configuration_carrier/delete', [
  72. CarrierInterface::CONFIGURATION_ID => $data[CarrierInterface::CONFIGURATION_ID]
  73. ]);
  74. }
  75. /**
  76. * Obtain Add New Carrier url.
  77. *
  78. * @return string
  79. */
  80. public function getCarrierRegistrationPageUrl(): string
  81. {
  82. return $this->urlBuilder->getUrl('temando/configuration_carrier/register');
  83. }
  84. }