You are here

public function WebformAccessRulesManager::checkAccessRules in Webform 8.5

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

Check access for a given operation and set of access rules.

Parameters

string $operation: Operation that is being requested.

\Drupal\Core\Session\AccountInterface $account: Account that is requesting access to the operation.

array $access_rules: A set of access rules to check against.

Return value

bool TRUE if access is allowed and FALSE is access is denied.

Overrides WebformAccessRulesManagerInterface::checkAccessRules

2 calls to WebformAccessRulesManager::checkAccessRules()
WebformAccessRulesManager::checkWebformAccess in src/WebformAccessRulesManager.php
Check if operation is allowed through access rules for a given webform.
WebformAccessRulesManager::checkWebformSubmissionAccess in src/WebformAccessRulesManager.php
Check if operation is allowed through access rules for a submission.

File

src/WebformAccessRulesManager.php, line 135

Class

WebformAccessRulesManager
The webform access rules manager service.

Namespace

Drupal\webform

Code

public function checkAccessRules($operation, AccountInterface $account, array $access_rules) {

  // Check administer access rule and grant full access to user.
  if ($this
    ->checkAccessRule($access_rules['administer'], $account)) {
    return TRUE;
  }

  // Check operation.
  if (isset($access_rules[$operation]) && $this
    ->checkAccessRule($access_rules[$operation], $account)) {
    return TRUE;
  }
  return FALSE;
}