You are here

protected function YamlForm::checkAccessRule in YAML Form 8

Checks an access rule against a user account's roles and id.

Parameters

array $access_rule: An access rule.

\Drupal\Core\Session\AccountInterface $account: The user session for which to check access.

Return value

bool The access result. Returns a TRUE if access is allowed.

1 call to YamlForm::checkAccessRule()
YamlForm::checkAccessRules in src/Entity/YamlForm.php
Checks form access to an operation on a form's submission.

File

src/Entity/YamlForm.php, line 646

Class

YamlForm
Defines the form entity.

Namespace

Drupal\yamlform\Entity

Code

protected function checkAccessRule(array $access_rule, AccountInterface $account) {
  if (!empty($access_rule['roles']) && array_intersect($access_rule['roles'], $account
    ->getRoles())) {
    return TRUE;
  }
  elseif (!empty($access_rule['users']) && in_array($account
    ->id(), $access_rule['users'])) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}