Completed
Push — master ( f8c4bd...25c22e )
by Nate
09:23 queued 07:32
created

AbstractObjectAction::setMessage()   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 1
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
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
abstract class AbstractObjectAction extends SavableComponent implements ObjectActionInterface
20
{
21
    /**
22
     * The message that should be displayed to the user after the action is performed.
23
     *
24
     * @var string
25
     */
26
    private $message;
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public static function isDestructive(): bool
32
    {
33
        return false;
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function getTriggerLabel(): string
40
    {
41
        return static::displayName();
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function getTriggerHtml()
48
    {
49
        return null;
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function getConfirmationMessage()
56
    {
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public function performAction(Objects $field, ElementInterface $element): bool
63
    {
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