AbstractIntegrationAction::performAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-integration/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-integration/
7
 */
8
9
namespace flipbox\craft\integration\fields\actions;
10
11
use craft\base\ElementInterface;
12
use craft\base\SavableComponent;
13
use flipbox\craft\integration\fields\Integrations;
14
15
abstract class AbstractIntegrationAction extends SavableComponent implements IntegrationActionInterface
16
{
17
    /**
18
     * The message that should be displayed to the user after the action is performed.
19
     *
20
     * @var string
21
     */
22
    private $message;
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public static function isDestructive(): bool
28
    {
29
        return false;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function getTriggerLabel(): string
36
    {
37
        return static::displayName();
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function getTriggerHtml()
44
    {
45
        return null;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function getConfirmationMessage()
52
    {
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public function performAction(Integrations $field, ElementInterface $element): bool
59
    {
60
        return true;
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function getMessage()
67
    {
68
        return $this->message;
69
    }
70
71
    /**
72
     * Sets the message that should be displayed to the user after the action is performed.
73
     *
74
     * @param string $message The message that should be displayed to the user after the action is performed.
75
     */
76
    protected function setMessage(string $message)
77
    {
78
        $this->message = $message;
79
    }
80
81
    /**
82
     * @inheritdoc
83
     */
84
    public function attributes()
85
    {
86
        return array_merge(
87
            parent::attributes(),
88
            [
89
                'message'
90
            ]
91
        );
92
    }
93
}
94