function RestPermissions::permissions

Same name in other branches
  1. 9 core/modules/rest/src/RestPermissions.php \Drupal\rest\RestPermissions::permissions()
  2. 8.9.x core/modules/rest/src/RestPermissions.php \Drupal\rest\RestPermissions::permissions()
  3. 11.x core/modules/rest/src/RestPermissions.php \Drupal\rest\RestPermissions::permissions()

Returns an array of REST permissions.

Return value

array

1 string reference to 'RestPermissions::permissions'
rest.permissions.yml in core/modules/rest/rest.permissions.yml
core/modules/rest/rest.permissions.yml

File

core/modules/rest/src/RestPermissions.php, line 55

Class

RestPermissions
Provides rest module permissions.

Namespace

Drupal\rest

Code

public function permissions() {
    $permissions = [];
    
    /** @var \Drupal\rest\RestResourceConfigInterface[] $resource_configs */
    $resource_configs = $this->resourceConfigStorage
        ->loadMultiple();
    foreach ($resource_configs as $resource_config) {
        $plugin = $resource_config->getResourcePlugin();
        // Add the rest resource configuration entity as a dependency to the
        // permissions.
        $permissions += array_map(function (array $permission_info) use ($resource_config) {
            $merge_info['dependencies'][$resource_config->getConfigDependencyKey()] = [
                $resource_config->getConfigDependencyName(),
            ];
            return NestedArray::mergeDeep($permission_info, $merge_info);
        }, $plugin->permissions());
    }
    return $permissions;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.