class CourseAccessControlHandler in Course 3.x
Same name and namespace in other branches
- 8.3 src/Access/CourseAccessControlHandler.php \Drupal\course\Access\CourseAccessControlHandler
- 8.2 src/Access/CourseAccessControlHandler.php \Drupal\course\Access\CourseAccessControlHandler
Access controller for the Course entity.
Hierarchy
- class \Drupal\course\Access\CourseAccessControlHandler extends \Drupal\entity\UncacheableEntityAccessControlHandler
Expanded class hierarchy of CourseAccessControlHandler
File
- src/
Access/ CourseAccessControlHandler.php, line 14
Namespace
Drupal\course\AccessView source
class CourseAccessControlHandler extends UncacheableEntityAccessControlHandler {
/**
* Handle multiple access denied messages (for enrolling and taking).
*
* {@inheritdoc}
*/
protected function processAccessHookResults(array $access) {
// @todo sort by weight and allow altering
return parent::processAccessHookResults($access);
}
/**
* Grant access to reports.
*
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CourseAccessControlHandler:: |
protected | function | Grant access to reports. | |
CourseAccessControlHandler:: |
protected | function | Handle multiple access denied messages (for enrolling and taking). |