Completed
Push — develop ( f8c4bd...63ca71 )
by Nate
02:47
created

AbstractObjectItemAction::isDestructive()   A

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
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\hubspot\fields\actions;
10
11
use craft\base\ElementInterface;
12
use craft\base\SavableComponent;
13
use flipbox\hubspot\fields\Objects;
14
use flipbox\hubspot\records\ObjectAssociation;
15
16
abstract class AbstractObjectItemAction extends SavableComponent implements ObjectItemActionInterface
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(
60
        Objects $field,
61
        ElementInterface $element,
62
        ObjectAssociation $record
63
    ): bool {
64
        return true;
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function getMessage()
71
    {
72
        return $this->message;
73
    }
74
75
    /**
76
     * Sets the message that should be displayed to the user after the action is performed.
77
     *
78
     * @param string $message The message that should be displayed to the user after the action is performed.
79
     */
80
    protected function setMessage(string $message)
81
    {
82
        $this->message = $message;
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function attributes()
89
    {
90
        return array_merge(
91
            parent::attributes(),
92
            [
93
                'message'
94
            ]
95
        );
96
    }
97
}
98