You are here

public static function WebformAccountAccess::checkUserSubmissionsAccess in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Access/WebformAccountAccess.php \Drupal\webform\Access\WebformAccountAccess::checkUserSubmissionsAccess()

Check whether the user can view own submissions.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

\Drupal\user\UserInterface $user: The access checked routes' associated user account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 string reference to 'WebformAccountAccess::checkUserSubmissionsAccess'
webform.routing.yml in ./webform.routing.yml
webform.routing.yml

File

src/Access/WebformAccountAccess.php, line 79

Class

WebformAccountAccess
Defines the custom access control handler for the user accounts.

Namespace

Drupal\webform\Access

Code

public static function checkUserSubmissionsAccess(AccountInterface $account, UserInterface $user) {
  $condition = $account
    ->hasPermission('administer webform') || $account
    ->hasPermission('administer webform submission') || $account
    ->hasPermission('view any webform submission') || $account
    ->hasPermission('access webform submission user') && $account
    ->id() === $user
    ->id();
  return AccessResult::allowedIf($condition)
    ->cachePerPermissions();
}