You are here

public function ResourceBase::permissions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/src/Plugin/ResourceBase.php \Drupal\rest\Plugin\ResourceBase::permissions()
  2. 9 core/modules/rest/src/Plugin/ResourceBase.php \Drupal\rest\Plugin\ResourceBase::permissions()

Implements ResourceInterface::permissions().

Every plugin operation method gets its own user permission. Example: "restful delete entity:node" with the title "Access DELETE on Node resource".

Overrides ResourceInterface::permissions

1 call to ResourceBase::permissions()
ResourceBase::getBaseRouteRequirements in core/modules/rest/src/Plugin/ResourceBase.php
Gets the base route requirements for a particular method.
2 methods override ResourceBase::permissions()
EntityResource::permissions in core/modules/rest/src/Plugin/rest/resource/EntityResource.php
Implements ResourceInterface::permissions().
FileUploadResource::permissions in core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
Implements ResourceInterface::permissions().

File

core/modules/rest/src/Plugin/ResourceBase.php, line 83

Class

ResourceBase
Common base class for resource plugins.

Namespace

Drupal\rest\Plugin

Code

public function permissions() {
  $permissions = [];
  $definition = $this
    ->getPluginDefinition();
  foreach ($this
    ->availableMethods() as $method) {
    $lowered_method = strtolower($method);
    $permissions["restful {$lowered_method} {$this->pluginId}"] = [
      'title' => $this
        ->t('Access @method on %label resource', [
        '@method' => $method,
        '%label' => $definition['label'],
      ]),
    ];
  }
  return $permissions;
}