Passed
Pull Request — master (#396)
by
unknown
08:43
created

CheckApplePayConfiguration::_prepareLayout()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * @category  Payone
18
 * @package   Payone_Magento2_Plugin
19
 * @author    FATCHIP GmbH <[email protected]>
20
 * @copyright 2003 - 2021 Payone GmbH
21
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
22
 * @link      http://www.payone.de
23
 */
24
25
namespace Payone\Core\Block\Adminhtml\Config\Form\Field;
26
27
use Payone\Core\Model\PayoneConfig;
28
29
/**
30
 * Admin-block for the Ratepay refresh profile button
31
 */
32
class CheckApplePayConfiguration extends \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...
33
{
34
    /**
35
     * @var \Payone\Core\Helper\ApplePay
36
     */
37
    protected $applePayHelper;
38
39
    /**
40
     * Constructor
41
     *
42
     * @param \Magento\Backend\Block\Template\Context   $context
43
     * @param \Payone\Core\Helper\ApplePay              $applePayHelper
44
     * @param array                                     $data
45
     */
46
    public function __construct(
47
        \Magento\Backend\Block\Template\Context $context,
0 ignored issues
show
Bug introduced by
The type Magento\Backend\Block\Template\Context 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...
48
        \Payone\Core\Helper\ApplePay $applePayHelper,
49
        array $data = []
50
    ) {
51
        parent::__construct($context, $data);
52
        $this->applePayHelper = $applePayHelper;
53
    }
54
55
    /**
56
     * Set template to itself
57
     *
58
     * @return \Payone\Core\Block\Adminhtml\Config\Form\Field\CheckApplePayConfiguration
59
     */
60
    protected function _prepareLayout()
61
    {
62
        parent::_prepareLayout();
63
        if (!$this->getTemplate()) {
64
            $this->setTemplate('system/config/form/field/check_applepay_configuration.phtml');
65
        }
66
        return $this;
67
    }
68
69
    /**
70
     * Unset some non-related element parameters
71
     *
72
     * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
73
     * @return string
74
     */
75
    public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
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...
76
    {
77
        $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
78
        return parent::render($element);
79
    }
80
81
    /**
82
     * Get the button and scripts contents
83
     *
84
     * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
85
     * @return string
86
     */
87
    protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
88
    {
89
        $this->addData(['html_id' => $element->getHtmlId()]);
90
91
        return $this->_toHtml();
92
    }
93
94
    /**
95
     * Checks if all needed configuration fields are correctly configured
96
     *
97
     * @return bool
98
     */
99
    public function isConfigurationComplete()
100
    {
101
        return $this->applePayHelper->isConfigurationComplete();
102
    }
103
104
    /**
105
     * Check if merchant id configured
106
     *
107
     * @return bool
108
     */
109
    public function hasMerchantId()
110
    {
111
        return $this->applePayHelper->hasMerchantId();
112
    }
113
114
    /**
115
     * Check if certificate file is configured and exists
116
     *
117
     * @return bool
118
     */
119
    public function hasCertificateFile()
120
    {
121
        return $this->applePayHelper->hasCertificateFile();
122
    }
123
124
    /**
125
     * Check if private key file is configured and exists
126
     *
127
     * @return bool
128
     */
129
    public function hasPrivateKeyFile()
130
    {
131
        return $this->applePayHelper->hasPrivateKeyFile();
132
    }
133
}
134