public function LearningPathStepsController::startAccess in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::startAccess()
Check if the user has access to start the Learning Path.
1 string reference to 'LearningPathStepsController::startAccess'
File
- src/
Controller/ LearningPathStepsController.php, line 748
Class
- LearningPathStepsController
- Class LearningPathStepsController.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function startAccess(Group $group) {
if ($group
->bundle() !== 'learning_path') {
return AccessResult::neutral();
}
$user = $this
->currentUser();
$group_visibility = $group
->get('field_learning_path_visibility')
->getValue()[0]['value'];
if ($user
->isAnonymous() && $group_visibility != 'public') {
return AccessResult::forbidden();
}
$access = LearningPathAccess::statusGroupValidation($group, $user);
if ($access === FALSE) {
return AccessResult::forbidden();
}
return AccessResult::allowed();
}