public static function LearningPathAccess::getGroupContentAccess in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/LearningPathAccess.php \Drupal\opigno_learning_path\LearningPathAccess::getGroupContentAccess()
Returns Opigno course/module access flag.
1 call to LearningPathAccess::getGroupContentAccess()
- opigno_learning_path_opigno_module_access in ./
opigno_learning_path.module - Restricts user access to Learning Path content.
File
- src/
LearningPathAccess.php, line 60
Class
- LearningPathAccess
- Class LearningPathAccess.
Namespace
Drupal\opigno_learning_pathCode
public static function getGroupContentAccess(EntityInterface $entity, AccountInterface $account) {
$access = TRUE;
$contentID = OpignoGroupContext::getCurrentGroupContentId();
if (!empty($contentID)) {
$contents = OpignoGroupManagedContent::loadByProperties([
'id' => $contentID,
]);
if ($contents = array_shift($contents)) {
$learningPath = $contents
->getGroup();
if (isset($learningPath) && $learningPath
->getEntityTypeId() === 'learning_path' && !$learningPath
->access('view', $account)) {
$access = FALSE;
}
}
}
return $access;
}