CreateEanAttributeButton   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 72
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAjaxUrl() 0 4 1
A getButtonHtml() 0 11 1
A render() 0 7 1
A _construct() 0 5 1
A _getElementHtml() 0 4 1
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