You are here

public function MeetingListBuilder::getDefaultOperations in Opigno Moxtra 8

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

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides EntityListBuilder::getDefaultOperations

File

src/MeetingListBuilder.php, line 46

Class

MeetingListBuilder
Provides a list controller for opigno_moxtra_meeting entity.

Namespace

Drupal\opigno_moxtra

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  $operations['score'] = [
    'title' => $this
      ->t('Score'),
    'weight' => 10,
    'url' => Url::fromRoute('opigno_moxtra.score_meeting', [
      'opigno_moxtra_meeting' => $entity
        ->id(),
    ], [
      'query' => [
        'destination' => 'admin/content/moxtra/meeting',
      ],
      'absolute' => TRUE,
    ]),
  ];
  $gid = $entity
    ->getTrainingId();
  if ($gid) {
    $tid = _tft_get_group_tid($gid);
    $elements = _tft_folder_content($tid, TRUE, $gid);
    if ($elements) {
      $recordings_folder_exists = FALSE;
      foreach ($elements as $element) {
        if ($element['name'] == 'Recorded Live Meetings') {
          $tid = $element['id'];
          $recordings_folder_exists = TRUE;
          break;
        }
      }
      if ($recordings_folder_exists) {
        $elements = _tft_folder_content($tid, FALSE, $gid);
        if ($elements) {
          foreach ($elements as $element) {
            if ($element['type'] != 'term') {
              $media = Media::load($element['id']);
              if ($media && $media
                ->get('opigno_moxtra_recording_link')
                ->getValue()) {
                $operations['download'] = [
                  'title' => $this
                    ->t('Download'),
                  'weight' => 11,
                  'url' => Url::fromUri("internal:/tft/download/file/{$media->id()}"),
                ];
              }
            }
          }
        }
      }
    }
  }
  return $operations;
}