You are here

public function LearningPathContentController::coursesIndex in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::coursesIndex()

Root page for angular app.

1 string reference to 'LearningPathContentController::coursesIndex'
opigno_learning_path.routing.yml in ./opigno_learning_path.routing.yml
opigno_learning_path.routing.yml

File

src/Controller/LearningPathContentController.php, line 58

Class

LearningPathContentController
Controller for all the actions of the Learning Path content.

Namespace

Drupal\opigno_learning_path\Controller

Code

public function coursesIndex(Group $group, Request $request) {

  // Check if user has uncompleted steps.
  $validation = LearningPathValidator::stepsValidate($group);
  $gid = $group
    ->id();
  if ($validation instanceof RedirectResponse) {
    return $validation;
  }
  $group_type = $group
    ->get('type')
    ->getString();
  $next_link = $this
    ->getNextLink($group);
  $view_type = $group_type == 'opigno_course' ? 'manager' : 'modules';
  $tempstore = \Drupal::service('tempstore.private')
    ->get('opigno_group_manager');
  return [
    '#theme' => 'opigno_learning_path_courses',
    '#attached' => [
      'library' => [
        'opigno_group_manager/manage_app',
      ],
    ],
    '#base_path' => $request
      ->getBasePath(),
    '#base_href' => $request
      ->getPathInfo(),
    '#learning_path_id' => $gid,
    '#group_type' => $group_type,
    '#view_type' => $view_type,
    '#next_link' => isset($next_link) ? render($next_link) : NULL,
    '#user_has_info_card' => $tempstore
      ->get('hide_info_card') ? FALSE : TRUE,
    '#parent_learning_path' => $group_type == 'learning_path' ? '?learning_path=' . $gid : '',
  ];
}