Passed
Branch master (acde85)
by Alexander
01:40
created

Checker::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace B2Binpay\Payment\Block\Adminhtml\System\Config;
4
5
use Magento\Config\Block\System\Config\Form\Field;
0 ignored issues
show
Bug introduced by
The type Magento\Config\Block\System\Config\Form\Field was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Magento\Framework\Data\Form\Element\AbstractElement;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Data\F...Element\AbstractElement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Class Checker
10
 */
11
class Checker extends Field
12
{
13
    /**
14
     * Path to block template
15
     */
16
    const CHECK_TEMPLATE = 'B2Binpay_Payment::system/config/check.phtml';
17
18
    /**
19
     * Set template to itself
20
     *
21
     * @return $this
22
     */
23
    protected function _prepareLayout()
24
    {
25
        parent::_prepareLayout();
26
27
        if (!$this->getTemplate()) {
28
            $this->setTemplate(static::CHECK_TEMPLATE);
29
        }
30
31
        return $this;
32
    }
33
34
    /**
35
     * @param AbstractElement $element
36
     *
37
     * @return string
38
     */
39
    public function render(AbstractElement $element)
40
    {
41
        $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
42
43
        return parent::render($element);
44
    }
45
46
    /**
47
     * @param AbstractElement $element
48
     *
49
     * @return string
50
     */
51
    public function _getElementHtml(AbstractElement $element)
52
    {
53
        return $this->_toHtml();
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getAjaxUrl()
60
    {
61
        return $this->getUrl('b2binpay/system_config/check');
62
    }
63
64
    /**
65
     * @return mixed
66
     * @throws \Magento\Framework\Exception\LocalizedException
67
     */
68
    public function getButtonHtml()
69
    {
70
        $buttonData = ['id' => 'b2binpay_check_button', 'label' => __('Check Auth')];
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        $buttonData = ['id' => 'b2binpay_check_button', 'label' => /** @scrutinizer ignore-call */ __('Check Auth')];
Loading history...
71
        $button = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button')->setData($buttonData);
72
73
        return $button->toHtml();
74
    }
75
}
76