public function LearningPathStepsController::nextStepAccess in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::nextStepAccess()
Check if the user has access to any next content from the Learning Path.
File
- src/
Controller/ LearningPathStepsController.php, line 730
Class
- LearningPathStepsController
- Class LearningPathStepsController.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function nextStepAccess(Group $group, OpignoGroupManagedContent $parent_content) {
// Check if there is a next step and if the user has access to it.
// Get the user score of the parent content.
// First, get the content type object of the parent content.
$content_type = $this->content_type_manager
->createInstance($parent_content
->getGroupContentTypeId());
$user_score = $content_type
->getUserScore(\Drupal::currentUser()
->id(), $parent_content
->getEntityId());
// If no no score and content is mandatory, return forbidden.
if ($user_score === FALSE && $parent_content
->isMandatory()) {
return AccessResult::forbidden();
}
return AccessResult::allowed();
}