1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Slack API library. |
5
|
|
|
* |
6
|
|
|
* (c) Cas Leentfaar <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace CL\Slack\Model; |
13
|
|
|
|
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Cas Leentfaar <[email protected]> |
18
|
|
|
* |
19
|
|
|
* @link Official documentation at https://api.slack.com/docs/attachments |
20
|
|
|
*/ |
21
|
|
|
class Attachment extends AbstractModel |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $title; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $titleLink; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $imageUrl; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $authorName; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
private $authorLink; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $authorIcon; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
private $preText; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
private $text; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
private $color; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var string |
70
|
|
|
*/ |
71
|
|
|
private $fallback; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
private $callbackId; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var AttachmentField[]|ArrayCollection |
80
|
|
|
*/ |
81
|
|
|
private $fields; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var AttachmentAction[]|ArrayCollection |
85
|
|
|
*/ |
86
|
|
|
private $actions; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @var Array |
90
|
|
|
*/ |
91
|
|
|
private $mrkdwnIn; |
92
|
|
|
|
93
|
1 |
|
public function __construct() |
94
|
|
|
{ |
95
|
1 |
|
$this->fields = new ArrayCollection(); |
96
|
1 |
|
$this->actions = new ArrayCollection(); |
97
|
1 |
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param string $title |
101
|
|
|
*/ |
102
|
1 |
|
public function setTitle($title) |
103
|
|
|
{ |
104
|
1 |
|
$this->title = $title; |
105
|
1 |
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
1 |
|
public function getTitle() |
111
|
|
|
{ |
112
|
1 |
|
return $this->title; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param string $titleLink |
117
|
|
|
*/ |
118
|
1 |
|
public function setTitleLink($titleLink) |
119
|
|
|
{ |
120
|
1 |
|
$this->titleLink = $titleLink; |
121
|
1 |
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
1 |
|
public function getTitleLink() |
127
|
|
|
{ |
128
|
1 |
|
return $this->titleLink; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $imageUrl |
133
|
|
|
*/ |
134
|
1 |
|
public function setImageUrl($imageUrl) |
135
|
|
|
{ |
136
|
1 |
|
$this->imageUrl = $imageUrl; |
137
|
1 |
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
1 |
|
public function getImageUrl() |
143
|
|
|
{ |
144
|
1 |
|
return $this->imageUrl; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param string $authorName |
149
|
|
|
*/ |
150
|
1 |
|
public function setAuthorName($authorName) |
151
|
|
|
{ |
152
|
1 |
|
$this->authorName = $authorName; |
153
|
1 |
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
1 |
|
public function getAuthorName() |
159
|
|
|
{ |
160
|
1 |
|
return $this->authorName; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param string $authorLink |
165
|
|
|
*/ |
166
|
1 |
|
public function setAuthorLink($authorLink) |
167
|
|
|
{ |
168
|
1 |
|
$this->authorLink = $authorLink; |
169
|
1 |
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return string |
173
|
|
|
*/ |
174
|
1 |
|
public function getAuthorLink() |
175
|
|
|
{ |
176
|
1 |
|
return $this->authorLink; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param string $authorIcon |
181
|
|
|
*/ |
182
|
1 |
|
public function setAuthorIcon($authorIcon) |
183
|
|
|
{ |
184
|
1 |
|
$this->authorIcon = $authorIcon; |
185
|
1 |
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return string |
189
|
|
|
*/ |
190
|
1 |
|
public function getAuthorIcon() |
191
|
|
|
{ |
192
|
1 |
|
return $this->authorIcon; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param string $fallback Required text summary of the attachment that is shown by clients that understand attachments |
197
|
|
|
* but choose not to show them. |
198
|
|
|
*/ |
199
|
1 |
|
public function setFallback($fallback) |
200
|
|
|
{ |
201
|
1 |
|
$this->fallback = $fallback; |
202
|
1 |
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return string Text summary of the attachment that is shown by clients that understand attachments |
206
|
|
|
* but choose not to show them. |
207
|
|
|
*/ |
208
|
2 |
|
public function getFallback() |
209
|
|
|
{ |
210
|
2 |
|
return $this->fallback; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @param string $callbackId Required if the attachment contains actions |
215
|
|
|
*/ |
216
|
|
|
public function setCallbackId($callbackId) |
217
|
|
|
{ |
218
|
|
|
$this->callbackId = $callbackId; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @return string Returns the callback id |
223
|
|
|
*/ |
224
|
1 |
|
public function getCallbackId() |
225
|
|
|
{ |
226
|
1 |
|
return $this->callbackId; |
227
|
|
|
} |
228
|
|
|
/** |
229
|
|
|
* @param string|null $preText Optional text that should appear above the formatted data. |
230
|
|
|
*/ |
231
|
1 |
|
public function setPreText($preText = null) |
232
|
|
|
{ |
233
|
1 |
|
$this->preText = $preText; |
234
|
1 |
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return string|null Optional text that should appear above the formatted data. |
238
|
|
|
*/ |
239
|
2 |
|
public function getPreText() |
240
|
|
|
{ |
241
|
2 |
|
return $this->preText; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param string|null $text Optional text that should appear within the attachment. |
246
|
|
|
*/ |
247
|
1 |
|
public function setText($text = null) |
248
|
|
|
{ |
249
|
1 |
|
$this->text = $text; |
250
|
1 |
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @return string|null Optional text that should appear within the attachment. |
254
|
|
|
*/ |
255
|
2 |
|
public function getText() |
256
|
|
|
{ |
257
|
2 |
|
return $this->text; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @param string|null $color Can either be one of 'good', 'warning', 'danger', or any hex color code |
262
|
|
|
*/ |
263
|
1 |
|
public function setColor($color = null) |
264
|
|
|
{ |
265
|
1 |
|
$this->color = $color; |
266
|
1 |
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @return string|null Can either be one of 'good', 'warning', 'danger', or any hex color code |
270
|
|
|
*/ |
271
|
2 |
|
public function getColor() |
272
|
|
|
{ |
273
|
2 |
|
return $this->color; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @param AttachmentField $field |
278
|
|
|
*/ |
279
|
1 |
|
public function addField(AttachmentField $field) |
280
|
|
|
{ |
281
|
1 |
|
$this->fields->add($field); |
282
|
1 |
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @return AttachmentField[]|ArrayCollection |
286
|
|
|
*/ |
287
|
2 |
|
public function getFields() |
288
|
|
|
{ |
289
|
2 |
|
return $this->fields; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @param array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
294
|
|
|
*/ |
295
|
|
|
public function setMrkdwnIn(Array $mrkdwnIn) |
296
|
|
|
{ |
297
|
|
|
$this->mrkdwnIn = $mrkdwnIn; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @return Array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
302
|
|
|
*/ |
303
|
|
|
public function getMrkdwnIn() |
304
|
|
|
{ |
305
|
|
|
return $this->mrkdwnIn; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @param AttachmentAction $action |
311
|
|
|
*/ |
312
|
1 |
|
public function addAction(AttachmentAction $action) |
313
|
|
|
{ |
314
|
1 |
|
$this->actions->add($action); |
315
|
1 |
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @return AttachmentAction[]|ArrayCollection |
319
|
|
|
*/ |
320
|
2 |
|
public function getActions() |
321
|
|
|
{ |
322
|
2 |
|
return $this->actions; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
} |
326
|
|
|
|