-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathButton.php
More file actions
55 lines (46 loc) · 1.31 KB
/
Button.php
File metadata and controls
55 lines (46 loc) · 1.31 KB
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
<?php
namespace Amazon\Pay\Block\Adminhtml\System\Config;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Button extends Field
{
protected $_template = 'Amazon_Pay::system/config/button.phtml';
/**
* @param AbstractElement $element
* @return mixed
*/
public function render(AbstractElement $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}
/**
* @param AbstractElement $element
* @return mixed
*/
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
/**
* @return mixed
*/
public function getCustomUrl()
{
return $this->getUrl('amazon_pay/spc/synctokens');
}
/**
* @return mixed
*/
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button')
->setData([
'id' => 'sync_tokens',
'label' => __('Generate & sync tokens'),
'on_click' => sprintf("location.href = '%s';", $this->getCustomUrl()),
]);
return $button->toHtml();
}
}