PaymentReleaseButton::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
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\SplitExampleMagento\Plugin\Magento\Sales\Block\Adminhtml\Order;
10
11
use Getnet\SplitExampleMagento\Helper\Data;
12
use Magento\Sales\Block\Adminhtml\Order\View;
13
14
/**
15
 * Class Payment Release Button - Add button for payment release.
16
 */
17
class PaymentReleaseButton
18
{
19
    /**
20
     * @var Config
0 ignored issues
show
Bug introduced by
The type Getnet\SplitExampleMagen...\Adminhtml\Order\Config 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...
21
     */
22
    protected $config;
23
24
    /**
25
     * @param Data $config
26
     */
27
    public function __construct(
28
        Data $config
29
    ) {
30
        $this->config = $config;
0 ignored issues
show
Documentation Bug introduced by
It seems like $config of type Getnet\SplitExampleMagento\Helper\Data is incompatible with the declared type Getnet\SplitExampleMagen...\Adminhtml\Order\Config of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31
    }
32
33
    /**
34
     * Before Convert.
35
     *
36
     * @param View $subject
37
     */
38
    public function beforeSetLayout(
39
        View $subject
40
    ) {
41
        $typeRelease = $this->config->getTypeRelease();
42
43
        if ($typeRelease !== 'not_applicable') {
44
            $message = __('Are you sure you want to do this?');
45
            $url = $subject->getUrl('getnet/order/paymentRelease');
46
47
            $subject->addButton(
48
                'payment_release',
49
                [
50
                    'label'   => __('Payment Release'),
51
                    'onclick' => "confirmSetLocation('{$message}', '{$url}')",
52
                    'class'   => 'reset',
53
                ],
54
                -1
55
            );
56
        }
57
    }
58
}
59