AbstractIntegrationItemAction::isDestructive()   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 0
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
use flipbox\craft\integration\records\IntegrationAssociation;
15
16
abstract class AbstractIntegrationItemAction extends SavableComponent implements IntegrationItemActionInterface
17
{
18
    /**
19
     * The message that should be displayed to the user after the action is performed.
20
     *
21
     * @var string
22
     */
23
    private $message;
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public static function isDestructive(): bool
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function getTriggerLabel(): string
37
    {
38
        return static::displayName();
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function getTriggerHtml()
45
    {
46
        return null;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function getConfirmationMessage()
53
    {
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function performAction(Integrations $field, ElementInterface $element, IntegrationAssociation $record): bool
60
    {
61
        return true;
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function getMessage()
68
    {
69
        return $this->message;
70
    }
71
72
    /**
73
     * Sets the message that should be displayed to the user after the action is performed.
74
     *
75
     * @param string $message The message that should be displayed to the user after the action is performed.
76
     */
77
    protected function setMessage(string $message)
78
    {
79
        $this->message = $message;
80
    }
81
82
    /**
83
     * @inheritdoc
84
     */
85
    public function attributes()
86
    {
87
        return array_merge(
88
            parent::attributes(),
89
            [
90
                'message'
91
            ]
92
        );
93
    }
94
}
95