You are here

public function MeetingController::index in Opigno Moxtra 8

Same name and namespace in other branches
  1. 3.x src/Controller/MeetingController.php \Drupal\opigno_moxtra\Controller\MeetingController::index()

Returns index page for the live meeting.

Parameters

\Drupal\opigno_moxtra\MeetingInterface $opigno_moxtra_meeting: The Live Meeting.

Return value

array Render array.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'MeetingController::index'
opigno_moxtra.routing.yml in ./opigno_moxtra.routing.yml
opigno_moxtra.routing.yml

File

src/Controller/MeetingController.php, line 285

Class

MeetingController
Class MeetingController.

Namespace

Drupal\opigno_moxtra\Controller

Code

public function index(MeetingInterface $opigno_moxtra_meeting) {
  $owner_id = $opigno_moxtra_meeting
    ->getOwnerId();
  $session_key = $opigno_moxtra_meeting
    ->getSessionKey();
  $info = $this->moxtraService
    ->getMeetingInfo($owner_id, $session_key);
  $content = [];
  $status = !empty($info['data']) ? $info['data']['status'] : FALSE;
  switch ($status) {
    case 'SESSION_SCHEDULED':
      $content[] = $this
        ->buildMeetingScheduled($opigno_moxtra_meeting);
      break;
    case 'SESSION_STARTED':
      $content[] = $this
        ->buildMeetingStarted($opigno_moxtra_meeting);
      break;
    case 'SESSION_ENDED':
      $uid = $this
        ->currentUser()
        ->id();
      $gid = $opigno_moxtra_meeting
        ->getTrainingId();
      if (isset($gid) && $opigno_moxtra_meeting
        ->isMember($uid)) {

        // Update user achievements.
        $step = opigno_learning_path_get_meeting_step($gid, $uid, $opigno_moxtra_meeting);
        opigno_learning_path_save_step_achievements($gid, $uid, $step, 0);
        opigno_learning_path_save_achievements($gid, $uid);
      }
      $content[] = $this
        ->buildMeetingEnded($opigno_moxtra_meeting);
      break;
  }
  return $content;
}