public function LearningPathStepsController::contentSteps in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::contentSteps()
Steps.
1 string reference to 'LearningPathStepsController::contentSteps'
File
- src/
Controller/ LearningPathStepsController.php, line 653
Class
- LearningPathStepsController
- Class LearningPathStepsController.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function contentSteps(Group $group, $current) {
// Check if user has uncompleted steps.
LearningPathValidator::stepsValidate($group);
// Get group type.
$type = opigno_learning_path_get_group_type();
// Get all steps.
$all_steps = opigno_learning_path_get_routes_steps();
// Get unique steps numbers.
$unique_steps = array_unique($all_steps);
// Get next step.
$next_step = $current < count($unique_steps) ? $current + 1 : NULL;
// If last step.
if (!$next_step) {
if ($type == 'learning_path') {
return $this
->redirect('opigno_learning_path.manager.publish', [
'group' => $group
->id(),
]);
}
else {
// For courses and classes.
return $this
->redirect('entity.group.canonical', [
'group' => $group
->id(),
]);
}
}
else {
if ($type == 'learning_path') {
// Check for existing courses in the LP.
// If there are no courses - skip courses step.
$group_courses = $group
->getContent('subgroup:opigno_course');
if ($current == 2 && empty($group_courses)) {
$next_step++;
}
}
// For all group types.
$route = array_search($next_step, opigno_learning_path_get_routes_steps());
return $this
->redirect($route, [
'group' => $group
->id(),
]);
}
}