You are here

public function ResourceBase::permissions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

File

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

Class

ResourceBase
Common base class for resource plugins.

Namespace

Drupal\rest\Plugin

Code

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