You are here

public function WebformAccessRulesManager::getAccessRulesInfo in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformAccessRulesManager.php \Drupal\webform\WebformAccessRulesManager::getAccessRulesInfo()

Collect metadata on known access rules.

Return value

array Array that describes all known access rules. It will be keyed by access rule machine-name and will contain sub arrays with the following structure:

  • title: (string) Human-friendly translated string that describes the meaning of this access rule.
  • description: (array) Renderable array that explains what this access rule stands for. Defaults to an empty array.
  • roles: (string[]) Array of role IDs that should be granted this access rule by default. Defaults to an empty array.
  • permissions: (string[]) Array of permissions that should be granted this access rule by default. Defaults to an empty array.

Overrides WebformAccessRulesManagerInterface::getAccessRulesInfo

1 call to WebformAccessRulesManager::getAccessRulesInfo()
WebformAccessRulesManager::getDefaultAccessRules in src/WebformAccessRulesManager.php
Returns the webform default access rules.

File

src/WebformAccessRulesManager.php, line 100

Class

WebformAccessRulesManager
The webform access rules manager service.

Namespace

Drupal\webform

Code

public function getAccessRulesInfo() {
  $access_rules = $this->moduleHandler
    ->invokeAll('webform_access_rules');
  $this->moduleHandler
    ->alter('webform_access_rules', $access_rules);

  // Set access rule default values.
  foreach ($access_rules as $access_rule => $info) {
    $access_rules[$access_rule] += [
      'title' => NULL,
      'description' => NULL,
      'weight' => 0,
      'roles' => [],
      'users' => [],
      'permissions' => [],
    ];
  }
  uasort($access_rules, [
    SortArray::class,
    'sortByWeightElement',
  ]);
  return $access_rules;
}