public function StepsBlock::getLinkToStart in Opigno Learning path 3.x
1 call to StepsBlock::getLinkToStart()
- StepsBlock::processModuleList in src/
Plugin/ Block/ StepsBlock.php - Process module list.
File
- src/
Plugin/ Block/ StepsBlock.php, line 254
Class
- StepsBlock
- Provides a 'article' block.
Namespace
Drupal\opigno_learning_path\Plugin\BlockCode
public function getLinkToStart($step) : ?Url {
$link = NULL;
/** @var \Drupal\opigno_learning_path\Controller\LearningPathStepsController $controller */
$controller = \Drupal::classResolver(LearningPathStepsController::class);
if ($step['step_first']) {
return $this
->getLink($step);
}
else {
$group_id = $this
->getCurrentGroupId();
$parent_content_id = $step["step_previous"]["cid"];
$group = Group::load($group_id);
$course_entity = OpignoGroupManagedContent::load($parent_content_id);
$resp = $controller
->getNextStep($group, $course_entity, FALSE);
if (($resp["#type"] ?? FALSE) != 'html_tag') {
// @todo an access to link should be checked here.
//
// if the response is a html type, that means the function returns
// a redirect message, because we reuse the legacy code
// that actually is not developed for the checking an access to route.
return Url::fromRoute('opigno_learning_path.steps.next', [
'group' => $group_id,
'parent_content' => $parent_content_id,
]);
}
}
return $link;
}