CourseAccessControlHandler.php in Course 3.x
File
src/Access/CourseAccessControlHandler.php
View source
<?php
namespace Drupal\course\Access;
use Drupal\Core\Access\AccessResultAllowed;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\entity\UncacheableEntityAccessControlHandler;
class CourseAccessControlHandler extends UncacheableEntityAccessControlHandler {
protected function processAccessHookResults(array $access) {
return parent::processAccessHookResults($access);
}
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'report') {
if ($account
->hasPermission('access all course reports')) {
return AccessResultAllowed::allowed();
}
else {
return parent::checkAccess($entity, 'update', $account);
}
}
return parent::checkAccess($entity, $operation, $account);
}
}