1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Trello\Model; |
4
|
|
|
|
5
|
|
|
use Trello\Exception\InvalidArgumentException; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @codeCoverageIgnore |
9
|
|
|
*/ |
10
|
|
|
class Board extends AbstractObject implements BoardInterface |
11
|
|
|
{ |
12
|
|
|
protected $apiName = 'board'; |
13
|
|
|
|
14
|
|
|
protected $loadParams = array( |
15
|
|
|
'fields' => 'all', |
16
|
|
|
'organization' => true, |
17
|
|
|
'organization_memberships' => 'all', |
18
|
|
|
'members' => 'all', |
19
|
|
|
'membersInvited' => 'all', |
20
|
|
|
'memberships' => 'all', |
21
|
|
|
'lists' => 'all', |
22
|
|
|
); |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function setName($name) |
28
|
|
|
{ |
29
|
|
|
$this->data['name'] = $name; |
30
|
|
|
|
31
|
|
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function getName() |
38
|
|
|
{ |
39
|
|
|
return $this->data['name']; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public function setDescription($desc) |
46
|
|
|
{ |
47
|
|
|
$this->data['desc'] = $desc; |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
public function getDescription() |
56
|
|
|
{ |
57
|
|
|
return $this->data['desc']; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function getDescriptionData() |
64
|
|
|
{ |
65
|
|
|
return $this->data['descData']; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function getUrl() |
72
|
|
|
{ |
73
|
|
|
return $this->data['url']; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
public function getShortUrl() |
80
|
|
|
{ |
81
|
|
|
return $this->data['shortUrl']; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
|
|
public function getShortLink() |
88
|
|
|
{ |
89
|
|
|
return $this->data['shortLink']; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
public function setOrganizationId($organizationId) |
96
|
|
|
{ |
97
|
|
|
$this->data['idOrganization'] = $organizationId; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
*/ |
105
|
|
|
public function getOrganizationId() |
106
|
|
|
{ |
107
|
|
|
return $this->data['idOrganization']; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
*/ |
113
|
|
|
public function setOrganization(OrganizationInterface $organization) |
114
|
|
|
{ |
115
|
|
|
return $this->setOrganizationId($organization->getId()); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* {@inheritdoc} |
120
|
|
|
*/ |
121
|
|
|
public function getOrganization() |
122
|
|
|
{ |
123
|
|
|
return new Organization($this->client, $this->getOrganizationId()); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* {@inheritdoc} |
128
|
|
|
*/ |
129
|
|
|
public function getLists() |
130
|
|
|
{ |
131
|
|
|
$lists = array(); |
132
|
|
|
|
133
|
|
|
foreach ($this->data['lists'] as $data) { |
134
|
|
|
$lists[$data['id']] = new Cardlist($this->client, $data['id']); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return $lists; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* {@inheritdoc} |
142
|
|
|
*/ |
143
|
|
|
public function getList($idOrName) |
144
|
|
|
{ |
145
|
|
|
foreach ($this->getLists() as $list) { |
146
|
|
|
if ($list->getName() === $idOrName || $list->getId() === $idOrName) { |
147
|
|
|
return $list; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
throw new InvalidArgumentException(sprintf( |
152
|
|
|
'There is no list with name or id "%s" on this board ("%s")', |
153
|
|
|
$idOrName, |
154
|
|
|
$this->getName() |
155
|
|
|
)); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* {@inheritdoc} |
160
|
|
|
*/ |
161
|
|
|
public function setClosed($closed) |
162
|
|
|
{ |
163
|
|
|
$this->data['closed'] = $closed; |
164
|
|
|
|
165
|
|
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* {@inheritdoc} |
170
|
|
|
*/ |
171
|
|
|
public function isClosed() |
172
|
|
|
{ |
173
|
|
|
return $this->data['closed']; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* {@inheritdoc} |
178
|
|
|
*/ |
179
|
|
|
public function setPinned($pinned) |
180
|
|
|
{ |
181
|
|
|
$this->data['pinned'] = $pinned; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* {@inheritdoc} |
188
|
|
|
*/ |
189
|
|
|
public function isPinned() |
190
|
|
|
{ |
191
|
|
|
return $this->data['pinned']; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* {@inheritdoc} |
196
|
|
|
*/ |
197
|
|
|
public function setStarred($starred) |
198
|
|
|
{ |
199
|
|
|
$this->data['starred'] = $starred; |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* {@inheritdoc} |
206
|
|
|
*/ |
207
|
|
|
public function isStarred() |
208
|
|
|
{ |
209
|
|
|
return $this->data['starred']; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* {@inheritdoc} |
214
|
|
|
*/ |
215
|
|
|
public function setSubscribed($subscribed) |
216
|
|
|
{ |
217
|
|
|
$this->data['subscribed'] = $subscribed; |
218
|
|
|
|
219
|
|
|
return $this; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* {@inheritdoc} |
224
|
|
|
*/ |
225
|
|
|
public function isSubscribed() |
226
|
|
|
{ |
227
|
|
|
return $this->data['subscribed']; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* {@inheritdoc} |
232
|
|
|
*/ |
233
|
|
|
public function isInvited() |
234
|
|
|
{ |
235
|
|
|
return $this->data['invited']; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* {@inheritdoc} |
240
|
|
|
*/ |
241
|
|
|
public function setRequiredRoleToInvite($role) |
242
|
|
|
{ |
243
|
|
|
$this->data['invitations'] = $role; |
244
|
|
|
|
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* {@inheritdoc} |
250
|
|
|
*/ |
251
|
|
|
public function getRequiredRoleToInvite() |
252
|
|
|
{ |
253
|
|
|
return $this->data['invitations']; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* {@inheritdoc} |
258
|
|
|
*/ |
259
|
|
|
public function setMemberships(array $memberships) |
260
|
|
|
{ |
261
|
|
|
$this->data['memberships'] = $memberships; |
262
|
|
|
|
263
|
|
|
return $this; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* {@inheritdoc} |
268
|
|
|
*/ |
269
|
|
|
public function getMemberships() |
270
|
|
|
{ |
271
|
|
|
return $this->data['memberships']; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* {@inheritdoc} |
276
|
|
|
*/ |
277
|
|
|
public function setPreferences(array $prefs) |
278
|
|
|
{ |
279
|
|
|
$this->data['prefs'] = $prefs; |
280
|
|
|
|
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* {@inheritdoc} |
286
|
|
|
*/ |
287
|
|
|
public function getPreferences() |
288
|
|
|
{ |
289
|
|
|
return $this->data['prefs']; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* {@inheritdoc} |
294
|
|
|
*/ |
295
|
|
|
public function setLabelNames(array $labelNames) |
296
|
|
|
{ |
297
|
|
|
$this->data['labelNames'] = $labelNames; |
298
|
|
|
|
299
|
|
|
return $this; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* {@inheritdoc} |
304
|
|
|
*/ |
305
|
|
|
public function getLabelNames() |
306
|
|
|
{ |
307
|
|
|
return $this->data['labelNames']; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* {@inheritdoc} |
312
|
|
|
*/ |
313
|
|
|
public function setPowerUps(array $powerUps) |
314
|
|
|
{ |
315
|
|
|
$this->data['powerUps'] = $powerUps; |
316
|
|
|
|
317
|
|
|
return $this; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* {@inheritdoc} |
322
|
|
|
*/ |
323
|
|
|
public function getPowerUps() |
324
|
|
|
{ |
325
|
|
|
return $this->data['powerUps']; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* {@inheritdoc} |
330
|
|
|
*/ |
331
|
|
|
public function getDateOfLastActivity() |
332
|
|
|
{ |
333
|
|
|
return new \DateTime($this->data['dateLastActivity']); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* {@inheritdoc} |
338
|
|
|
*/ |
339
|
|
|
public function getDateOfLastView() |
340
|
|
|
{ |
341
|
|
|
return new \DateTime($this->data['dateLastView']); |
342
|
|
|
} |
343
|
|
|
} |
344
|
|
|
|