1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Stockbase\Integration\Block\Adminhtml\System\Config; |
5
|
|
|
|
6
|
|
|
use Magento\Backend\Block\Widget\Button; |
7
|
|
|
use Magento\Config\Block\System\Config\Form\Field; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* CreateEanAttributeButton block. |
11
|
|
|
*/ |
12
|
|
|
class CreateEanAttributeButton extends Field |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* {@inheritdoc} |
16
|
|
|
*/ |
17
|
|
|
public function __construct(\Magento\Backend\Block\Template\Context $context, array $data = []) |
18
|
|
|
{ |
19
|
|
|
parent::__construct($context, $data); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Gets the ajax url for the button. |
24
|
|
|
* |
25
|
|
|
* @return string |
26
|
|
|
*/ |
27
|
|
|
public function getAjaxUrl() |
28
|
|
|
{ |
29
|
|
|
return $this->getUrl('stockbase/system_config/createEanAttribute'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Generate button html |
34
|
|
|
* |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
public function getButtonHtml() |
38
|
|
|
{ |
39
|
|
|
/** @var Button $button */ |
40
|
|
|
$button = $this->getLayout()->createBlock(Button::class); |
41
|
|
|
$button->setData([ |
42
|
|
|
'id' => 'create_ean_attribute', |
43
|
|
|
'label' => __('Create EAN attribute'), |
44
|
|
|
]); |
45
|
|
|
|
46
|
|
|
return $button->toHtml(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Render button |
51
|
|
|
* |
52
|
|
|
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) |
56
|
|
|
{ |
57
|
|
|
// Remove scope label |
58
|
|
|
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); |
59
|
|
|
|
60
|
|
|
return parent::render($element); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
protected function _construct() |
67
|
|
|
{ |
68
|
|
|
parent::_construct(); |
69
|
|
|
$this->setTemplate('Stockbase_Integration::system/config/integration/create_ean_attribute.phtml'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Return element html |
74
|
|
|
* |
75
|
|
|
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element |
76
|
|
|
* @return string |
77
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
78
|
|
|
*/ |
79
|
|
|
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) |
80
|
|
|
{ |
81
|
|
|
return $this->_toHtml(); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|