Completed
Push — master ( f8c4bd...25c22e )
by Nate
09:23 queued 07:32
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
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
abstract class AbstractObjectItemAction extends SavableComponent implements ObjectItemActionInterface
21
{
22
    /**
23
     * The message that should be displayed to the user after the action is performed.
24
     *
25
     * @var string
26
     */
27
    private $message;
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public static function isDestructive(): bool
33
    {
34
        return false;
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function getTriggerLabel(): string
41
    {
42
        return static::displayName();
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function getTriggerHtml()
49
    {
50
        return null;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function getConfirmationMessage()
57
    {
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    public function performAction(
64
        Objects $field,
65
        ElementInterface $element,
66
        ObjectAssociation $record
67
    ): bool {
68
        return true;
69
    }
70
71
    /**
72
     * @inheritdoc
73
     */
74
    public function getMessage()
75
    {
76
        return $this->message;
77
    }
78
79
    /**
80
     * Sets the message that should be displayed to the user after the action is performed.
81
     *
82
     * @param string $message The message that should be displayed to the user after the action is performed.
83
     */
84
    protected function setMessage(string $message)
85
    {
86
        $this->message = $message;
87
    }
88
89
    /**
90
     * @inheritdoc
91
     */
92
    public function attributes()
93
    {
94
        return array_merge(
95
            parent::attributes(),
96
            [
97
                'message'
98
            ]
99
        );
100
    }
101
}
102