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
13 
18 class Edit extends \Magento\Backend\Block\Widget\Form\Container
19 {
25  protected $_coreRegistry = null;
26 
32  public function __construct(
33  \Magento\Backend\Block\Widget\Context $context,
34  \Magento\Framework\Registry $registry,
35  array $data = []
36  ) {
37  $this->_coreRegistry = $registry;
38  parent::__construct($context, $data);
39  }
40 
46  protected function _construct()
47  {
48  $this->_objectId = 'instance_id';
49  $this->_blockGroup = 'Magento_Widget';
50  $this->_controller = 'adminhtml_widget_instance';
51  parent::_construct();
52  }
53 
59  public function getWidgetInstance()
60  {
61  return $this->_coreRegistry->registry('current_widget_instance');
62  }
63 
70  protected function _preparelayout()
71  {
72  if ($this->getWidgetInstance()->isCompleteToCreate()) {
73  $this->buttonList->add(
74  'save_and_edit_button',
75  [
76  'label' => __('Save and Continue Edit'),
77  'class' => 'save',
78  'data_attribute' => [
79  'mage-init' => [
80  'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'],
81  ],
82  ]
83  ],
84  100
85  );
86  } else {
87  $this->removeButton('save');
88  }
89  return parent::_prepareLayout();
90  }
91 
97  public function getHeaderText()
98  {
99  if ($this->getWidgetInstance()->getId()) {
100  return __('Widget "%1"', $this->escapeHtml($this->getWidgetInstance()->getTitle()));
101  } else {
102  return __('New Widget Instance');
103  }
104  }
105 
111  public function getValidationUrl()
112  {
113  return $this->getUrl('adminhtml/*/validate', ['_current' => true]);
114  }
115 
121  public function getSaveUrl()
122  {
123  return $this->getUrl('adminhtml/*/save', ['_current' => true, 'back' => null]);
124  }
125 }
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, array $data=[])
Definition: Edit.php:32
__()
Definition: __.php:13