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 AttachmentField[]|ArrayCollection |
75
|
|
|
*/ |
76
|
|
|
private $fields; |
77
|
|
|
|
78
|
|
|
private $footer; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @var Array |
82
|
|
|
*/ |
83
|
|
|
private $mrkdwnIn; |
84
|
|
|
|
85
|
1 |
|
public function __construct() |
86
|
|
|
{ |
87
|
1 |
|
$this->fields = new ArrayCollection(); |
88
|
1 |
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param string $title |
92
|
|
|
*/ |
93
|
1 |
|
public function setTitle($title) |
94
|
|
|
{ |
95
|
1 |
|
$this->title = $title; |
96
|
1 |
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return string |
100
|
|
|
*/ |
101
|
1 |
|
public function getTitle() |
102
|
|
|
{ |
103
|
1 |
|
return $this->title; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param string $titleLink |
108
|
|
|
*/ |
109
|
1 |
|
public function setTitleLink($titleLink) |
110
|
|
|
{ |
111
|
1 |
|
$this->titleLink = $titleLink; |
112
|
1 |
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
1 |
|
public function getTitleLink() |
118
|
|
|
{ |
119
|
1 |
|
return $this->titleLink; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param string $imageUrl |
124
|
|
|
*/ |
125
|
1 |
|
public function setImageUrl($imageUrl) |
126
|
|
|
{ |
127
|
1 |
|
$this->imageUrl = $imageUrl; |
128
|
1 |
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
1 |
|
public function getImageUrl() |
134
|
|
|
{ |
135
|
1 |
|
return $this->imageUrl; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param string $authorName |
140
|
|
|
*/ |
141
|
1 |
|
public function setAuthorName($authorName) |
142
|
|
|
{ |
143
|
1 |
|
$this->authorName = $authorName; |
144
|
1 |
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
1 |
|
public function getAuthorName() |
150
|
|
|
{ |
151
|
1 |
|
return $this->authorName; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param string $authorLink |
156
|
|
|
*/ |
157
|
1 |
|
public function setAuthorLink($authorLink) |
158
|
|
|
{ |
159
|
1 |
|
$this->authorLink = $authorLink; |
160
|
1 |
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return string |
164
|
|
|
*/ |
165
|
1 |
|
public function getAuthorLink() |
166
|
|
|
{ |
167
|
1 |
|
return $this->authorLink; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param string $authorIcon |
172
|
|
|
*/ |
173
|
1 |
|
public function setAuthorIcon($authorIcon) |
174
|
|
|
{ |
175
|
1 |
|
$this->authorIcon = $authorIcon; |
176
|
1 |
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return string |
180
|
|
|
*/ |
181
|
1 |
|
public function getAuthorIcon() |
182
|
|
|
{ |
183
|
1 |
|
return $this->authorIcon; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $fallback Required text summary of the attachment that is shown by clients that understand attachments |
188
|
|
|
* but choose not to show them. |
189
|
|
|
*/ |
190
|
1 |
|
public function setFallback($fallback) |
191
|
|
|
{ |
192
|
1 |
|
$this->fallback = $fallback; |
193
|
1 |
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return string Text summary of the attachment that is shown by clients that understand attachments |
197
|
|
|
* but choose not to show them. |
198
|
|
|
*/ |
199
|
2 |
|
public function getFallback() |
200
|
|
|
{ |
201
|
2 |
|
return $this->fallback; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param string|null $preText Optional text that should appear above the formatted data. |
206
|
|
|
*/ |
207
|
1 |
|
public function setPreText($preText = null) |
208
|
|
|
{ |
209
|
1 |
|
$this->preText = $preText; |
210
|
1 |
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @return string|null Optional text that should appear above the formatted data. |
214
|
|
|
*/ |
215
|
2 |
|
public function getPreText() |
216
|
|
|
{ |
217
|
2 |
|
return $this->preText; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @param string|null $text Optional text that should appear within the attachment. |
222
|
|
|
*/ |
223
|
1 |
|
public function setText($text = null) |
224
|
|
|
{ |
225
|
1 |
|
$this->text = $text; |
226
|
1 |
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @return string|null Optional text that should appear within the attachment. |
230
|
|
|
*/ |
231
|
2 |
|
public function getText() |
232
|
|
|
{ |
233
|
2 |
|
return $this->text; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @param string|null $color Can either be one of 'good', 'warning', 'danger', or any hex color code |
238
|
|
|
*/ |
239
|
1 |
|
public function setColor($color = null) |
240
|
|
|
{ |
241
|
1 |
|
$this->color = $color; |
242
|
1 |
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @return string|null Can either be one of 'good', 'warning', 'danger', or any hex color code |
246
|
|
|
*/ |
247
|
2 |
|
public function getColor() |
248
|
|
|
{ |
249
|
2 |
|
return $this->color; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @param AttachmentField $field |
254
|
|
|
*/ |
255
|
1 |
|
public function addField(AttachmentField $field) |
256
|
|
|
{ |
257
|
1 |
|
$this->fields->add($field); |
258
|
1 |
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @return AttachmentField[]|ArrayCollection |
262
|
|
|
*/ |
263
|
2 |
|
public function getFields() |
264
|
|
|
{ |
265
|
2 |
|
return $this->fields; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @param array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
270
|
|
|
*/ |
271
|
|
|
public function setMrkdwnIn(Array $mrkdwnIn) |
272
|
|
|
{ |
273
|
|
|
$this->mrkdwnIn = $mrkdwnIn; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @return Array Valid values for mrkdwn_in are: ["pretext", "text", "fields"]. Setting "fields" will enable markup formatting for the value of each field |
278
|
|
|
*/ |
279
|
|
|
public function getMrkdwnIn() |
280
|
|
|
{ |
281
|
|
|
return $this->mrkdwnIn; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @return mixed |
286
|
|
|
*/ |
287
|
|
|
public function getFooter() |
288
|
|
|
{ |
289
|
|
|
return $this->footer; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @param mixed $footer |
294
|
|
|
*/ |
295
|
|
|
public function setFooter($footer) |
296
|
|
|
{ |
297
|
|
|
$this->footer = $footer; |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
|