public function WebformAccessRulesManager::checkWebformSubmissionAccess in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformAccessRulesManager.php \Drupal\webform\WebformAccessRulesManager::checkWebformSubmissionAccess()
Check if operation is allowed through access rules for a submission.
Parameters
string $operation: Operation to check.
\Drupal\Core\Session\AccountInterface $account: Account who is requesting the operation.
\Drupal\webform\WebformSubmissionInterface $webform_submission: Webform submission on which the operation is requested.
Return value
\Drupal\Core\Access\AccessResultInterface Access result.
Overrides WebformAccessRulesManagerInterface::checkWebformSubmissionAccess
File
- src/
WebformAccessRulesManager.php, line 49
Class
- WebformAccessRulesManager
- The webform access rules manager service.
Namespace
Drupal\webformCode
public function checkWebformSubmissionAccess($operation, AccountInterface $account, WebformSubmissionInterface $webform_submission) {
$webform = $webform_submission
->getWebform();
$access_rules = $this
->getAccessRules($webform);
$cache_per_user = $this
->cachePerUser($access_rules);
// Check operation.
if ($this
->checkAccessRules($operation, $account, $access_rules)) {
return WebformAccessResult::allowed($webform_submission, $cache_per_user);
}
// Check *_own operation.
if ($webform_submission
->isOwner($account) && isset($access_rules[$operation . '_own']) && $this
->checkAccessRule($access_rules[$operation . '_own'], $account)) {
return WebformAccessResult::allowed($webform_submission, $cache_per_user);
}
// Check *_any operation.
if (isset($access_rules[$operation . '_any']) && $this
->checkAccessRule($access_rules[$operation . '_any'], $account)) {
return WebformAccessResult::allowed($webform_submission, $cache_per_user);
}
return WebformAccessResult::neutral($webform_submission, $cache_per_user);
}