You are here

protected function MeetingController::buildMeetingScheduled in Opigno Moxtra 8

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

Returns render array for the scheduled live meeting.

Parameters

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

Return value

array Render array.

1 call to MeetingController::buildMeetingScheduled()
MeetingController::index in src/Controller/MeetingController.php
Returns index page for the live meeting.

File

src/Controller/MeetingController.php, line 119

Class

MeetingController
Class MeetingController.

Namespace

Drupal\opigno_moxtra\Controller

Code

protected function buildMeetingScheduled(MeetingInterface $opigno_moxtra_meeting) {
  $training_id = $opigno_moxtra_meeting
    ->getTrainingId();
  $user = $this
    ->currentUser();
  if (!$user
    ->hasPermission('start meeting')) {
    return [
      '#type' => 'container',
      'message' => [
        '#markup' => $this
          ->t('This live meeting has not started yet<br />Come back later...'),
      ],
      'navigation' => $this
        ->buildNavigation($opigno_moxtra_meeting),
    ];
  }
  $config = $this
    ->config('opigno_moxtra.settings');
  $client_id = $config
    ->get('client_id');
  $org_id = $config
    ->get('org_id');
  $access_token = $this->moxtraConnector
    ->getToken();
  $binder_id = $opigno_moxtra_meeting
    ->getBinderId();
  $session_key = $opigno_moxtra_meeting
    ->getSessionKey();
  $topic = $opigno_moxtra_meeting
    ->getTitle();
  $invitees = [];
  $members = $opigno_moxtra_meeting
    ->getMembers();
  foreach ($members as $member) {
    $prefix = $this->moxtraConnector
      ->prefix($member);
    $invitees[] = [
      'unique_id' => $prefix . $member
        ->id(),
    ];
  }
  $url = $this->moxtraConnector
    ->getUrl();
  return [
    '#type' => 'container',
    'meeting_container' => [
      '#type' => 'container',
      '#attributes' => [
        'id' => 'live-meeting-container',
      ],
    ],
    'start_btn' => [
      '#markup' => '<div class="start-meeting"><a href="#" id="start-meeting">' . $this
        ->t('Start the live meeting') . '<i class="icon-play-circle"></i></div></a>',
    ],
    'navigation' => $this
      ->buildNavigation($opigno_moxtra_meeting),
    '#attached' => [
      'library' => [
        'opigno_moxtra/moxtra.js',
        'opigno_moxtra/meeting_scheduled',
      ],
      'drupalSettings' => [
        'opignoMoxtra' => [
          'mode' => 'production',
          'clientId' => $client_id,
          'orgId' => $org_id,
          'accessToken' => $access_token,
          'binderId' => $binder_id,
          'sessionKey' => $session_key,
          'topic' => $topic,
          'baseDomain' => $url,
          'invitees' => $invitees,
        ],
      ],
    ],
  ];
}