You are here

public function LearningPathStepsController::startAccess in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 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'
opigno_learning_path.routing.yml in ./opigno_learning_path.routing.yml
opigno_learning_path.routing.yml

File

src/Controller/LearningPathStepsController.php, line 765

Class

LearningPathStepsController
Class LearningPathStepsController.

Namespace

Drupal\opigno_learning_path\Controller

Code

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();
}