You are here

public function OpignoLearningPathProgress::render in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Plugin/views/field/OpignoLearningPathProgress.php \Drupal\opigno_learning_path\Plugin\views\field\OpignoLearningPathProgress::render()

Throws

\Exception

Overrides FieldPluginBase::render

File

src/Plugin/views/field/OpignoLearningPathProgress.php, line 31

Class

OpignoLearningPathProgress
Field handler to output user progress for current LP.

Namespace

Drupal\opigno_learning_path\Plugin\views\field

Code

public function render(ResultRow $values) {
  $account = \Drupal::currentUser();
  $uid = $account
    ->id();

  // Get an entity object.
  $entity = $values->_entity;
  $group = $entity instanceof LatestActivity ? $entity
    ->getTraining() : $entity;
  if (!is_null($group)) {
    $progress_service = \Drupal::service('opigno_learning_path.progress');
    return $progress_service
      ->getProgressAjaxContainer($group
      ->id(), $account
      ->id(), '', 'mini');
  }
  return '';
}