You are here

public function OpignoStatisticsAccess::accessModule in Opigno statistics 8

Same name and namespace in other branches
  1. 3.x src/Access/OpignoStatisticsAccess.php \Drupal\opigno_statistics\Access\OpignoStatisticsAccess::accessModule()

Checks access for a route with group and module in params.

1 string reference to 'OpignoStatisticsAccess::accessModule'
opigno_statistics.routing.yml in ./opigno_statistics.routing.yml
opigno_statistics.routing.yml

File

src/Access/OpignoStatisticsAccess.php, line 26

Class

OpignoStatisticsAccess
Opigno Statistics Access.

Namespace

Drupal\opigno_statistics\Access

Code

public function accessModule(UserInterface $user, GroupInterface $training, OpignoModule $module) {
  $account = \Drupal::currentUser();

  // Allow users to view their own profile.
  if ($account
    ->id() === $user
    ->id()) {
    return AccessResult::allowed();
  }
  return opigno_statistics_group_access($training, 'view statistics', $account);
}