-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateApiKeyButton.php
62 lines (54 loc) · 1.42 KB
/
GenerateApiKeyButton.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Auctane\Api\Block\System\Config;
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
class GenerateApiKeyButton extends Field
{
/**
* @var string
*/
protected $_template = 'Auctane_Api::system/config/generate.phtml';
/**
* Remove scope label
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}
/**
* Return ajax url for synchronize button
*
* @return string
*/
public function getApiKeyGenerationUrl()
{
return $this->getUrl('auctane_api/apikey');
}
/**
* Generate synchronize button html
*
* @return string
*/
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
)->setData(
[
'class' => 'primary',
'id' => 'generate_and_save_api_key',
'label' => __('Generate and save api key'),
]
);
return $button->toHtml();
}
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
}