Edit.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Block\Adminhtml\EventStream;
  6. use Magento\Backend\Block\Widget\Container;
  7. use Magento\Backend\Block\Widget\Context;
  8. use Temando\Shipping\Model\Config\ModuleConfigInterface;
  9. /**
  10. * Class Edit
  11. *
  12. * @package Temando\Shipping\Block
  13. * @author Max Melzer <max.melzer@netresearch.de>
  14. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  15. * @link http://www.temando.com/
  16. *
  17. * @api
  18. */
  19. class Edit extends Container
  20. {
  21. /**
  22. * @var ModuleConfigInterface
  23. */
  24. private $config;
  25. /**
  26. * Edit constructor.
  27. *
  28. * @param Context $context
  29. * @param ModuleConfigInterface $config
  30. * @param mixed[] $data
  31. */
  32. public function __construct(
  33. Context $context,
  34. ModuleConfigInterface $config,
  35. array $data = []
  36. ) {
  37. $this->config = $config;
  38. parent::__construct($context, $data);
  39. }
  40. /**
  41. * Add action buttons.
  42. *
  43. * @return \Magento\Framework\View\Element\AbstractBlock
  44. */
  45. protected function _prepareLayout()
  46. {
  47. $buttonData = [
  48. 'label' => __('Back'),
  49. 'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
  50. 'class' => 'back'
  51. ];
  52. $this->addButton('back', $buttonData, -1);
  53. $buttonData = [
  54. 'label' => __('Save'),
  55. 'class' => 'save primary',
  56. 'onclick' => 'document.getElementById("sync_form").submit();',
  57. ];
  58. $this->addButton('save', $buttonData, -1);
  59. return parent::_prepareLayout();
  60. }
  61. /**
  62. * @return string
  63. */
  64. public function getBackUrl()
  65. {
  66. return $this->getUrl('adminhtml/system_config/edit', [
  67. 'section' => 'carriers',
  68. '_fragment' => 'carriers_temando-link',
  69. ]);
  70. }
  71. /**
  72. * @return string
  73. */
  74. public function getSaveUrl()
  75. {
  76. return $this->_urlBuilder->getUrl('*/*/save');
  77. }
  78. /**
  79. * @return mixed[][]
  80. */
  81. public function getInputs()
  82. {
  83. $fields = [
  84. [
  85. 'heading' => __('Entities to sync'),
  86. 'label' => __('Shipment'),
  87. 'name' => 'sync_shipment',
  88. 'id' => 'sync_shipment',
  89. 'checked' => $this->config->isSyncShipmentEnabled(),
  90. 'disabled' => ''
  91. ],
  92. ];
  93. return $fields;
  94. }
  95. /**
  96. * @return mixed[]
  97. */
  98. public function getInputEnable()
  99. {
  100. return [
  101. 'label' => __('Enable sync'),
  102. 'name' => 'sync_enable',
  103. 'id' => 'sync_enable',
  104. 'checked' => $this->config->isSyncEnabled()
  105. ];
  106. }
  107. }