1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2018 |
5
|
|
|
* Nathan Boiron <[email protected]> |
6
|
|
|
* Romain Canon <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
10
|
|
|
* under the terms of the GNU General Public License, either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, see: |
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack; |
18
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Notification\CustomSettingsNotification; |
20
|
|
|
use CuyZ\Notiz\Domain\Notification\EntityNotification; |
21
|
|
|
use CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\Processor\EntitySlackNotificationProcessor; |
22
|
|
|
use CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\Settings\EntitySlackSettings; |
23
|
|
|
use CuyZ\Notiz\Domain\Notification\Slack\SlackNotification; |
24
|
|
|
|
25
|
|
|
class EntitySlackNotification extends EntityNotification implements SlackNotification, CustomSettingsNotification |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $message; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var bool |
34
|
|
|
*/ |
35
|
|
|
protected $customBot; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $bot; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $slackChannel; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $target; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $webhookUrl; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
protected $name; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
protected $avatar; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function getMessage() |
71
|
|
|
{ |
72
|
|
|
return $this->message; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string $message |
77
|
|
|
*/ |
78
|
|
|
public function setMessage($message) |
79
|
|
|
{ |
80
|
|
|
$this->message = $message; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
|
|
public function hasCustomBot() |
87
|
|
|
{ |
88
|
|
|
return $this->customBot; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param bool $customBot |
93
|
|
|
*/ |
94
|
|
|
public function setCustomBot($customBot) |
95
|
|
|
{ |
96
|
|
|
$this->customBot = $customBot; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
public function getBot() |
103
|
|
|
{ |
104
|
|
|
return $this->bot; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param string $bot |
109
|
|
|
*/ |
110
|
|
|
public function setBot($bot) |
111
|
|
|
{ |
112
|
|
|
$this->bot = $bot; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return bool |
117
|
|
|
*/ |
118
|
|
|
public function hasCustomSlackChannel() |
119
|
|
|
{ |
120
|
|
|
return !empty($this->target) || !empty($this->webhookUrl); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getSlackChannel() |
127
|
|
|
{ |
128
|
|
|
return $this->slackChannel; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $slackChannel |
133
|
|
|
*/ |
134
|
|
|
public function setSlackChannel($slackChannel) |
135
|
|
|
{ |
136
|
|
|
$this->slackChannel = $slackChannel; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
|
|
public function getWebhookUrl() |
143
|
|
|
{ |
144
|
|
|
return $this->webhookUrl; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param string $webhookUrl |
149
|
|
|
*/ |
150
|
|
|
public function setWebhookUrl($webhookUrl) |
151
|
|
|
{ |
152
|
|
|
$this->webhookUrl = $webhookUrl; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
|
|
public function getTarget() |
159
|
|
|
{ |
160
|
|
|
return $this->target; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param string $target |
165
|
|
|
*/ |
166
|
|
|
public function setTarget($target) |
167
|
|
|
{ |
168
|
|
|
$this->target = $target; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return string |
173
|
|
|
*/ |
174
|
|
|
public function getName() |
175
|
|
|
{ |
176
|
|
|
return $this->name; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param string $name |
181
|
|
|
*/ |
182
|
|
|
public function setName($name) |
183
|
|
|
{ |
184
|
|
|
$this->name = $name; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return string |
189
|
|
|
*/ |
190
|
|
|
public function getAvatar() |
191
|
|
|
{ |
192
|
|
|
return $this->avatar; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param string $avatar |
197
|
|
|
*/ |
198
|
|
|
public function setAvatar($avatar) |
199
|
|
|
{ |
200
|
|
|
$this->avatar = $avatar; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return string |
205
|
|
|
*/ |
206
|
|
|
public static function getProcessorClassName() |
207
|
|
|
{ |
208
|
|
|
return EntitySlackNotificationProcessor::class; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @return string |
213
|
|
|
*/ |
214
|
|
|
public static function getSettingsClassName() |
215
|
|
|
{ |
216
|
|
|
return EntitySlackSettings::class; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return string |
221
|
|
|
*/ |
222
|
|
|
public static function getDefinitionIdentifier() |
223
|
|
|
{ |
224
|
|
|
return 'entitySlack'; |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|