Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Edit.php
Go to the documentation of this file.
1 <?php
9 
12 
17 class Edit extends \Magento\Backend\Block\Widget\Form\Container
18 {
24  protected $_registry = null;
25 
30 
39  public function __construct(
40  \Magento\Backend\Block\Widget\Context $context,
41  \Magento\Framework\Registry $registry,
42  \Magento\Integration\Helper\Data $integrationHelper,
43  array $data = []
44  ) {
45  $this->_registry = $registry;
46  $this->_integrationHelper = $integrationHelper;
47  parent::__construct($context, $data);
48  }
49 
55  protected function _construct()
56  {
57  $this->_controller = 'adminhtml_integration';
58  $this->_blockGroup = 'Magento_Integration';
59  parent::_construct();
60  $this->buttonList->remove('reset');
61  $this->buttonList->remove('delete');
62 
63  if ($this->_integrationHelper->isConfigType(
64  $this->_registry->registry(Integration::REGISTRY_KEY_CURRENT_INTEGRATION)
65  )
66  ) {
67  $this->buttonList->remove('save');
68  }
69 
70  if ($this->_isNewIntegration()) {
71  $this->removeButton(
72  'save'
73  )->addButton(
74  'save',
75  [
76  'id' => 'save-split-button',
77  'label' => __('Save'),
78  'class_name' => \Magento\Backend\Block\Widget\Button\SplitButton::class,
79  'button_class' => '',
80  'data_attribute' => [
81  'mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']],
82  ],
83  'options' => [
84  'save_activate' => [
85  'id' => 'activate',
86  'label' => __('Save & Activate'),
87  'data_attribute' => [
88  'mage-init' => [
89  'button' => ['event' => 'saveAndActivate', 'target' => '#edit_form'],
90  'integration' => ['gridUrl' => $this->getUrl('*/*/')],
91  ],
92  ],
93  ],
94  ]
95  ]
96  );
97  }
98  }
99 
105  public function getHeaderText()
106  {
107  if ($this->_isNewIntegration()) {
108  return __('New Integration');
109  } else {
110  return __(
111  "Edit Integration '%1'",
112  $this->escapeHtml(
113  $this->_registry->registry(Integration::REGISTRY_KEY_CURRENT_INTEGRATION)[Info::DATA_NAME]
114  )
115  );
116  }
117  }
118 
122  public function getFormActionUrl()
123  {
124  return $this->getUrl('*/*/save');
125  }
126 
132  protected function _isNewIntegration()
133  {
134  return !isset($this->_registry->registry(Integration::REGISTRY_KEY_CURRENT_INTEGRATION)[Info::DATA_ID]);
135  }
136 }
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, \Magento\Integration\Helper\Data $integrationHelper, array $data=[])
Definition: Edit.php:39