Passed
Pull Request — main (#7)
by Bruno
03:18
created

PaymentGroup::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 12
rs 10
1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\PaymentMagento\Model\Adminhtml\Source;
10
11
/**
12
 * Class PaymentGroup - Fieldset renderer for getnet.
13
 */
14
class PaymentGroup extends \Magento\Config\Block\System\Config\Form\Fieldset
15
{
16
    /**
17
     * Return header comment part of html for fieldset
18
     *
19
     * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
20
     * @return string
21
     */
22
    protected function _getHeaderCommentHtml($element)
23
    {
24
        $groupConfig = $element->getGroup();
25
26
        if (empty($groupConfig['help_url']) || !$element->getComment()) {
27
            return parent::_getHeaderCommentHtml($element);
28
        }
29
30
        $html = '<div class="comment">' .
31
            $element->getComment() .
32
            ' <a target="_blank" href="' .
33
            $groupConfig['help_url'] .
34
            '">' .
35
            __(
36
                'Help'
37
            ) . '</a></div>';
38
39
        return $html;
40
    }
41
42
    /**
43
     * Return collapse state
44
     *
45
     * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
46
     * @return bool
47
     */
48
    protected function _isCollapseState($element)
49
    {
50
        $extra = $this->_authSession->getUser()->getExtra();
51
        if (isset($extra['configState'][$element->getId()])) {
52
            return $extra['configState'][$element->getId()];
53
        }
54
55
        $groupConfig = $element->getGroup();
56
        if (!empty($groupConfig['expanded'])) {
57
            return true;
58
        }
59
60
        return false;
61
    }
62
}
63