You are here

class OpignoStatisticsAccess in Opigno statistics 8

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

Opigno Statistics Access.

Hierarchy

Expanded class hierarchy of OpignoStatisticsAccess

File

src/Access/OpignoStatisticsAccess.php, line 13

Namespace

Drupal\opigno_statistics\Access
View source
class OpignoStatisticsAccess {

  /**
   * Checks access for a route with group in params.
   */
  public function accessGroup(UserInterface $user, GroupInterface $group) {
    $account = \Drupal::currentUser();
    return opigno_statistics_group_access($group, 'view statistics', $account);
  }

  /**
   * Checks access for a route with group and module in params.
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OpignoStatisticsAccess::accessGroup public function Checks access for a route with group in params.
OpignoStatisticsAccess::accessModule public function Checks access for a route with group and module in params.