You are here

protected function SaveMeetingRecordsQueue::getRecordingsFolder in Opigno Moxtra 8

Same name and namespace in other branches
  1. 3.x src/Plugin/QueueWorker/SaveMeetingRecordsQueue.php \Drupal\opigno_moxtra\Plugin\QueueWorker\SaveMeetingRecordsQueue::getRecordingsFolder()

Helper function that returns tid of the live meetings recordings folder.

Creates folder if it is not exists.

Parameters

int $group_id: Group ID.

Return value

\Drupal\taxonomy\TermInterface|null Taxonomy term ID of the recordings folder.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to SaveMeetingRecordsQueue::getRecordingsFolder()
SaveMeetingRecordsQueue::processItem in src/Plugin/QueueWorker/SaveMeetingRecordsQueue.php
Works on a single queue item.

File

src/Plugin/QueueWorker/SaveMeetingRecordsQueue.php, line 89

Class

SaveMeetingRecordsQueue
Save meeting records on CRON run.

Namespace

Drupal\opigno_moxtra\Plugin\QueueWorker

Code

protected function getRecordingsFolder($group_id) {
  $results =& drupal_static(__FUNCTION__);
  if (isset($results[$group_id])) {
    return $results[$group_id];
  }

  // Get the tid of the folder of the group.
  $group_folder_tid = _tft_get_group_tid($group_id);
  if ($group_folder_tid === NULL) {
    return NULL;
  }
  $recording_folder_name = $this
    ->t('Recorded Live Meetings');

  // Try get folder for the live meetings recordings.
  $recording_folder = NULL;

  /** @var \Drupal\taxonomy\TermStorageInterface $storage */
  $storage = $this->entityTypeManager
    ->getStorage('taxonomy_term');
  $children = $storage
    ->loadChildren($group_folder_tid);
  foreach ($children as $child) {
    if ($child
      ->label() === (string) $recording_folder_name) {
      $recording_folder = $child;
      break;
    }
  }

  // Create folder for the live meetings recordings if it is not exists.
  if (!isset($recording_folder)) {
    $recording_folder = Term::create([
      'vid' => 'tft_tree',
      'name' => $recording_folder_name,
      'parent' => $group_folder_tid,
    ]);
    $recording_folder
      ->save();
  }
  return $results[$group_id] = $recording_folder;
}