1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace JoisarJignesh\Bigbluebutton; |
5
|
|
|
|
6
|
|
|
use BigBlueButton\BigBlueButton; |
|
|
|
|
7
|
|
|
use BigBlueButton\Parameters\CreateMeetingParameters; |
8
|
|
|
use BigBlueButton\Parameters\DeleteRecordingsParameters; |
9
|
|
|
use BigBlueButton\Parameters\EndMeetingParameters; |
10
|
|
|
use BigBlueButton\Parameters\GetMeetingInfoParameters; |
11
|
|
|
use BigBlueButton\Parameters\GetRecordingsParameters; |
12
|
|
|
use BigBlueButton\Parameters\HooksCreateParameters; |
13
|
|
|
use BigBlueButton\Parameters\HooksDestroyParameters; |
14
|
|
|
use BigBlueButton\Parameters\IsMeetingRunningParameters; |
15
|
|
|
use BigBlueButton\Parameters\JoinMeetingParameters; |
16
|
|
|
use BigBlueButton\Parameters\PublishRecordingsParameters; |
17
|
|
|
use BigBlueButton\Parameters\SetConfigXMLParameters; |
18
|
|
|
use JoisarJignesh\Bigbluebutton\Services\initMeeting; |
19
|
|
|
|
20
|
|
|
class Bbb |
21
|
|
|
{ |
22
|
|
|
use initMeeting; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var |
26
|
|
|
*/ |
27
|
|
|
private $response; |
28
|
|
|
/** |
29
|
|
|
* @var BigBlueButton |
30
|
|
|
*/ |
31
|
|
|
protected $bbb; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Bbb constructor. |
36
|
|
|
* |
37
|
|
|
* @param BigBlueButton $bbb |
38
|
|
|
*/ |
39
|
|
|
public function __construct(BigBlueButton $bbb) |
40
|
|
|
{ |
41
|
|
|
$this->bbb = $bbb; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return BigBlueButton |
46
|
|
|
*/ |
47
|
|
|
public function make() |
48
|
|
|
{ |
49
|
|
|
return $this->bbb; |
50
|
|
|
} |
51
|
|
|
/** |
52
|
|
|
* Return a list of all meetings |
53
|
|
|
* |
54
|
|
|
* @return \Illuminate\Support\Collection |
55
|
|
|
*/ |
56
|
|
|
public function all() |
57
|
|
|
{ |
58
|
|
|
$this->response = $this->bbb->getMeetings(); |
59
|
|
View Code Duplication |
if ($this->response->success()) { |
|
|
|
|
60
|
|
|
if (count($this->response->getRawXml()->meetings->meeting) > 0) { |
61
|
|
|
$meetings = []; |
62
|
|
|
foreach ($this->response->getRawXml()->meetings->meeting as $meeting) { |
63
|
|
|
$meetings[] = XmlToArray($meeting); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return collect(XmlToArray($meetings)); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return collect([]); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* $meeting |
76
|
|
|
* |
77
|
|
|
* @param $meeting |
78
|
|
|
* |
79
|
|
|
* required fields |
80
|
|
|
* meetingID |
81
|
|
|
* meetingName |
82
|
|
|
* |
83
|
|
|
* @return mixed |
84
|
|
|
*/ |
85
|
|
View Code Duplication |
public function create($meeting) |
|
|
|
|
86
|
|
|
{ |
87
|
|
|
if (!$meeting instanceof CreateMeetingParameters) { |
88
|
|
|
$meeting = $this->initCreateMeeting($meeting); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$this->response = $this->bbb->createMeeting($meeting); |
92
|
|
|
if ($this->response->failed()) { |
93
|
|
|
return $this->response->getMessage(); |
94
|
|
|
} else { |
95
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param $meeting |
101
|
|
|
* |
102
|
|
|
* required fields: |
103
|
|
|
* meetingID |
104
|
|
|
* |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
|
View Code Duplication |
public function isMeetingRunning($meeting) |
|
|
|
|
108
|
|
|
{ |
109
|
|
|
if (!$meeting instanceof IsMeetingRunningParameters) { |
110
|
|
|
$meeting = $this->initIsMeetingRunning($meeting); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
$this->response = $this->bbb->isMeetingRunning($meeting); |
114
|
|
|
if ($this->response->success()) { |
115
|
|
|
$response = XmlToArray($this->response->getRawXml()); |
116
|
|
|
if (isset($response['running']) && $response['running'] == "true") { |
117
|
|
|
return true; |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
return false; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Join meeting |
126
|
|
|
* |
127
|
|
|
* @param $meeting |
128
|
|
|
* required fields |
129
|
|
|
* |
130
|
|
|
* meetingID |
131
|
|
|
* userName join by name |
132
|
|
|
* password which role want to join |
133
|
|
|
* |
134
|
|
|
* @return string |
135
|
|
|
*/ |
136
|
|
|
public function join($meeting) |
137
|
|
|
{ |
138
|
|
|
if (!$meeting instanceof JoinMeetingParameters) { |
139
|
|
|
$meeting = $this->initJoinMeeting($meeting); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
if ($meeting->isRedirect()) { |
143
|
|
|
return $this->bbb->getJoinMeetingURL($meeting); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
return $this->bbb->joinMeeting($meeting)->getUrl(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Returns information about the meeting |
151
|
|
|
* |
152
|
|
|
* @param $meeting |
153
|
|
|
* required fields |
154
|
|
|
* meetingID |
155
|
|
|
* moderatorPW must be there moderator password |
156
|
|
|
* |
157
|
|
|
* @return \Illuminate\Support\Collection |
158
|
|
|
*/ |
159
|
|
View Code Duplication |
public function getMeetingInfo($meeting) |
|
|
|
|
160
|
|
|
{ |
161
|
|
|
if (!$meeting instanceof GetMeetingInfoParameters) { |
162
|
|
|
$meeting = $this->initGetMeetingInfo($meeting); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
$this->response = $this->bbb->getMeetingInfo($meeting); |
166
|
|
|
if ($this->response->success()) { |
167
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
return collect([]); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param $parameters |
175
|
|
|
* |
176
|
|
|
* required fields |
177
|
|
|
* meetingID |
178
|
|
|
* meetingName |
179
|
|
|
* userName |
180
|
|
|
* attendeePW |
181
|
|
|
* moderatorPW |
182
|
|
|
* |
183
|
|
|
* @return mixed |
184
|
|
|
*/ |
185
|
|
|
public function start($parameters) |
186
|
|
|
{ |
187
|
|
|
return $this->initStart($parameters); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Close meeting |
192
|
|
|
* |
193
|
|
|
* @param $meeting |
194
|
|
|
* required fields: |
195
|
|
|
* meetingID |
196
|
|
|
* moderatorPW close meeting must be there moderator password |
197
|
|
|
* |
198
|
|
|
* @return bool |
199
|
|
|
*/ |
200
|
|
|
public function close($meeting) |
201
|
|
|
{ |
202
|
|
|
if (!$meeting instanceof EndMeetingParameters) { |
203
|
|
|
$meeting = $this->initCloseMeeting($meeting); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
$this->response = $this->bbb->endMeeting($meeting); |
207
|
|
|
if ($this->response->success()) { |
208
|
|
|
return true; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
return false; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* |
216
|
|
|
* @param $recording |
217
|
|
|
* required fields |
218
|
|
|
* meetingID |
219
|
|
|
* |
220
|
|
|
* optional fields |
221
|
|
|
* recordID |
222
|
|
|
* state |
223
|
|
|
* @return \Illuminate\Support\Collection |
224
|
|
|
*/ |
225
|
|
|
public function getRecordings($recording) |
226
|
|
|
{ |
227
|
|
|
if (!$recording instanceof GetRecordingsParameters) { |
228
|
|
|
$recording = $this->initGetRecordings($recording); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$this->response = $this->bbb->getRecordings($recording); |
232
|
|
View Code Duplication |
if (count($this->response->getRawXml()->recordings->recording) > 0) { |
|
|
|
|
233
|
|
|
$recordings = []; |
234
|
|
|
foreach ($this->response->getRawXml()->recordings->recording as $r) { |
235
|
|
|
$recordings[] = XmlToArray($r); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
return collect($recordings); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
return collect([]); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param $recording |
246
|
|
|
* recordID as string(sepeate by commma) |
247
|
|
|
* publish as bool |
248
|
|
|
* |
249
|
|
|
* @return bool |
250
|
|
|
*/ |
251
|
|
View Code Duplication |
public function publishRecordings($recording) |
|
|
|
|
252
|
|
|
{ |
253
|
|
|
if (!$recording instanceof PublishRecordingsParameters) { |
254
|
|
|
$recording = $this->initPublishRecordings($recording); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
$this->response = $this->bbb->publishRecordings($recording); |
258
|
|
|
if ($this->response->success()) { |
259
|
|
|
$response = XmlToArray($this->response->getRawXml()); |
260
|
|
|
if (isset($response['published']) && $response['published'] == "true") { |
261
|
|
|
return true; |
262
|
|
|
} |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
return false; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @param $recording |
270
|
|
|
* |
271
|
|
|
* required fields |
272
|
|
|
* recordingID |
273
|
|
|
* |
274
|
|
|
* @return \Illuminate\Support\Collection |
275
|
|
|
*/ |
276
|
|
|
public function deleteRecordings($recording) |
277
|
|
|
{ |
278
|
|
|
if (!$recording instanceof DeleteRecordingsParameters) { |
279
|
|
|
$recording = $this->initDeleteRecordings($recording); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
$this->response = $this->bbb->deleteRecordings($recording); |
283
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @param $configXml |
288
|
|
|
* |
289
|
|
|
* @return \Illuminate\Support\Collection |
290
|
|
|
*/ |
291
|
|
|
public function setConfigXml($configXml) |
292
|
|
|
{ |
293
|
|
|
if(!$configXml instanceof SetConfigXMLParameters){ |
294
|
|
|
$configXml = $this->initSetConfigXml($configXml); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
$this->response = $this->bbb->setConfigXML($configXml); |
298
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* @return \BigBlueButton\Responses\GetDefaultConfigXMLResponse |
303
|
|
|
*/ |
304
|
|
|
public function getDefaultConfigXml() |
305
|
|
|
{ |
306
|
|
|
$this->response = $this->bbb->getDefaultConfigXML(); |
307
|
|
|
return $this->response; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* @return \Illuminate\Support\Collection |
312
|
|
|
*/ |
313
|
|
|
public function getApiVersion() |
314
|
|
|
{ |
315
|
|
|
$this->response = $this->bbb->getApiVersion(); |
316
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* @param $hooks |
321
|
|
|
* |
322
|
|
|
* @return \Illuminate\Support\Collection |
323
|
|
|
*/ |
324
|
|
|
public function hooksCreate($hooks) |
325
|
|
|
{ |
326
|
|
|
if(!$hooks instanceof HooksCreateParameters){ |
327
|
|
|
$hooks = $this->initHooksCreate($hooks); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
$this->response = $this->bbb->hooksCreate($hooks); |
331
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @param $hooks |
336
|
|
|
* |
337
|
|
|
* @return \Illuminate\Support\Collection |
338
|
|
|
*/ |
339
|
|
|
public function hooksDestroy($hooks) |
340
|
|
|
{ |
341
|
|
|
if(!$hooks instanceof HooksDestroyParameters) { |
342
|
|
|
$hooks = $this->initHooksDestroy($hooks); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
$this->response = $this->bbb->hooksDestroy($hooks); |
346
|
|
|
return collect(XmlToArray($this->response->getRawXml())); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
} |
350
|
|
|
|
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: