DispatchEdit.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\ViewModel\Dispatch;
  6. use Magento\Framework\UrlInterface;
  7. use Magento\Framework\View\Element\Block\ArgumentInterface;
  8. use Temando\Shipping\ViewModel\DataProvider\DispatchUrl;
  9. use Temando\Shipping\ViewModel\DataProvider\EntityUrlInterface;
  10. use Temando\Shipping\ViewModel\DataProvider\ShippingApiAccess;
  11. use Temando\Shipping\ViewModel\DataProvider\ShippingApiAccessInterface;
  12. use Temando\Shipping\ViewModel\ShippingApiInterface;
  13. /**
  14. * View model for dispatch new/edit JS component.
  15. *
  16. * @package Temando\Shipping\ViewModel
  17. * @author Christoph Aßmann <christoph.assmann@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 DispatchEdit implements ArgumentInterface, ShippingApiInterface
  22. {
  23. /**
  24. * @var ShippingApiAccess
  25. */
  26. private $apiAccess;
  27. /**
  28. * @var DispatchUrl
  29. */
  30. private $dispatchUrl;
  31. /**
  32. * @var UrlInterface
  33. */
  34. private $urlBuilder;
  35. /**
  36. * DispatchEdit constructor.
  37. * @param ShippingApiAccess $apiAccess
  38. * @param DispatchUrl $dispatchUrl
  39. * @param UrlInterface $urlBuilder
  40. */
  41. public function __construct(
  42. ShippingApiAccess $apiAccess,
  43. DispatchUrl $dispatchUrl,
  44. UrlInterface $urlBuilder
  45. ) {
  46. $this->apiAccess = $apiAccess;
  47. $this->dispatchUrl = $dispatchUrl;
  48. $this->urlBuilder = $urlBuilder;
  49. }
  50. /**
  51. * @return ShippingApiAccessInterface
  52. */
  53. public function getShippingApiAccess(): ShippingApiAccessInterface
  54. {
  55. return $this->apiAccess;
  56. }
  57. /**
  58. * @return EntityUrlInterface|DispatchUrl
  59. */
  60. public function getDispatchUrl(): EntityUrlInterface
  61. {
  62. return $this->dispatchUrl;
  63. }
  64. /**
  65. * @return string
  66. */
  67. public function getShipmentViewPageUrl(): string
  68. {
  69. return $this->urlBuilder->getUrl('temando/shipment/view', ['shipment_id' => '--id--']);
  70. }
  71. }