public function OpignoTincanLiveMeeting::tincanLiveMeeting in Opigno TinCan API 3.x
Same name and namespace in other branches
- 8 modules/opigno_tincan_live_meeting/src/EventSubscriber/OpignoTincanLiveMeeting.php \Drupal\opigno_tincan_live_meeting\EventSubscriber\OpignoTincanLiveMeeting::tincanLiveMeeting()
Called whenever the tincanLiveMeeting event is dispatched.
Parameters
\Symfony\Component\EventDispatcher\Event $event: Event.
Throws
\Exception
File
- modules/
opigno_tincan_live_meeting/ src/ EventSubscriber/ OpignoTincanLiveMeeting.php, line 84
Class
- OpignoTincanLiveMeeting
- Class OpignoTincanLiveMeeting.
Namespace
Drupal\opigno_tincan_live_meeting\EventSubscriberCode
public function tincanLiveMeeting(Event $event) {
// Check if Tincan PHP library is installed.
$has_library = opigno_tincan_api_tincanphp_is_installed();
if (!$has_library) {
return;
}
$route_name = $this->route
->getRouteName();
// Statement must be send only from this route.
if ($route_name != 'opigno_moxtra.meeting') {
return;
}
/** @var \Drupal\opigno_moxtra\MeetingInterface[] $meetings */
$meeting = $this->route
->getParameter('opigno_moxtra_meeting');
// Check if statements was already sent.
$was_send = $this
->wasStatementSend($meeting);
if ($was_send) {
return;
}
// Get response about meeting from moxtra.
$owner_id = $meeting
->getOwnerId();
$session_key = $meeting
->getSessionKey();
$info = $this->moxtraService
->getMeetingInfo($owner_id, $session_key);
$status = !empty($info['data']) ? $info['data']['status'] : FALSE;
// Live meeting is ended.
if ($status == 'SESSION_ENDED') {
// User must be a participant of meeting.
$participants = $info['data']['participants'];
$is_participant = FALSE;
foreach ($participants as $participant) {
if ($participant['unique_id'] == $this->user
->id()) {
$is_participant = TRUE;
}
}
if ($is_participant) {
$this
->createAndSendTincanStatementsForMeeting($meeting, $info);
}
}
}