You are here

class UserSettingsAccess in Notify 2.0.x

Same name and namespace in other branches
  1. 8 src/Access/UserSettingsAccess.php \Drupal\notify\Access\UserSettingsAccess
  2. 1.0.x src/Access/UserSettingsAccess.php \Drupal\notify\Access\UserSettingsAccess

Class UserSettingsAccess.

To check permission to access UserSettings form.

@package Drupal\notify\Access

Hierarchy

Expanded class hierarchy of UserSettingsAccess

File

src/Access/UserSettingsAccess.php, line 16

Namespace

Drupal\notify\Access
View source
class UserSettingsAccess {

  /**
   * Checks access for the UserSettings form.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The route match.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(RouteMatchInterface $route_match, AccountInterface $account) {
    $current_user = $route_match
      ->getParameter('user');
    if ($current_user === $account
      ->id()) {
      return AccessResult::allowedIf($account
        ->hasPermission('access notify'));
    }
    return AccessResult::allowedIf($account
      ->hasPermission('administer notify'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UserSettingsAccess::access public function Checks access for the UserSettings form.