public function LearningPathContentController::getNextLink in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::getNextLink()
Returns next link.
Parameters
\Drupal\group\Entity\Group $group: Group.
Return value
array|mixed[]|null Next link.
2 calls to LearningPathContentController::getNextLink()
- LearningPathContentController::coursesIndex in src/
Controller/ LearningPathContentController.php - Root page for angular app.
- LearningPathContentController::modulesIndex in src/
Controller/ LearningPathContentController.php - Root page for angular app.
File
- src/
Controller/ LearningPathContentController.php, line 122
Class
- LearningPathContentController
- Controller for all the actions of the Learning Path content.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function getNextLink(Group $group) {
$next_link = NULL;
if ($group instanceof GroupInterface) {
$current_step = opigno_learning_path_get_current_step();
$user = \Drupal::currentUser();
if ($current_step == 4 && !$group
->access('administer members', $user)) {
// Hide link if user can't access members overview tab.
return NULL;
}
$group_type_id = $group
->getGroupType()
->id();
if ($group_type_id === 'learning_path') {
$next_step = $current_step < 5 ? $current_step + 1 : NULL;
$link_text = !$next_step ? t('Publish') : t('Next');
}
elseif ($group_type_id === 'opigno_course' && $current_step < 3) {
$link_text = t('Next');
}
else {
return $next_link;
}
$next_link = Link::createFromRoute($link_text, 'opigno_learning_path.content_steps', [
'group' => $group
->id(),
'current' => $current_step ? $current_step : 0,
], [
'attributes' => [
'class' => [
'btn',
'btn-success',
'color-white',
],
],
])
->toRenderable();
}
return $next_link;
}