protected function CourseAccessControlHandler::checkAccess in Course 3.x
Same name and namespace in other branches
- 8.3 src/Access/CourseAccessControlHandler.php \Drupal\course\Access\CourseAccessControlHandler::checkAccess()
- 8.2 src/Access/CourseAccessControlHandler.php \Drupal\course\Access\CourseAccessControlHandler::checkAccess()
Grant access to reports.
File
- src/
Access/ CourseAccessControlHandler.php, line 31
Class
- CourseAccessControlHandler
- Access controller for the Course entity.
Namespace
Drupal\course\AccessCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'report') {
if ($account
->hasPermission('access all course reports')) {
// If user has this permission then allow access without being able to
// update.
return AccessResultAllowed::allowed();
}
else {
// Otherwise, check if the user can update this course.
return parent::checkAccess($entity, 'update', $account);
}
}
return parent::checkAccess($entity, $operation, $account);
}