class WebformAccountAccess in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Access/WebformAccountAccess.php \Drupal\webform\Access\WebformAccountAccess
Defines the custom access control handler for the user accounts.
Hierarchy
- class \Drupal\webform\Access\WebformAccountAccess
Expanded class hierarchy of WebformAccountAccess
1 file declares its use of WebformAccountAccess
- WebformAccountAccessTest.php in tests/
src/ Unit/ Access/ WebformAccountAccessTest.php
File
- src/
Access/ WebformAccountAccess.php, line 12
Namespace
Drupal\webform\AccessView source
class WebformAccountAccess {
/**
* Check whether the user has 'administer webform' or 'administer webform submission' permission.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkAdminAccess(AccountInterface $account) {
return AccessResult::allowedIfHasPermissions($account, [
'administer webform',
'administer webform submission',
], 'OR');
}
/**
* Check whether the user has 'administer' or 'overview' permission.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkOverviewAccess(AccountInterface $account) {
return AccessResult::allowedIfHasPermissions($account, [
'administer webform',
'administer webform submission',
'access webform overview',
], 'OR');
}
/**
* Check whether the user has 'overview' with 'create' permission.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkTemplatesAccess(AccountInterface $account) {
$condition = $account
->hasPermission('access webform overview') && ($account
->hasPermission('administer webform') || $account
->hasPermission('create webform'));
return AccessResult::allowedIf($condition)
->cachePerPermissions();
}
/**
* Check whether the user can view submissions.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkSubmissionAccess(AccountInterface $account) {
return AccessResult::allowedIfHasPermissions($account, [
'administer webform',
'administer webform submission',
'view any webform submission',
], 'OR');
}
/**
* Check whether the user can view own submissions.
*
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
* @param \Drupal\user\UserInterface $user
* The access checked routes' associated user account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
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();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformAccountAccess:: |
public static | function | Check whether the user has 'administer webform' or 'administer webform submission' permission. | |
WebformAccountAccess:: |
public static | function | Check whether the user has 'administer' or 'overview' permission. | |
WebformAccountAccess:: |
public static | function | Check whether the user can view submissions. | |
WebformAccountAccess:: |
public static | function | Check whether the user has 'overview' with 'create' permission. | |
WebformAccountAccess:: |
public static | function | Check whether the user can view own submissions. |