Provides an array of permissions suitable for hook_permission().
Every plugin operation method gets its own user permission. Example: "restful delete entity:node" with the title "Access DELETE on Node resource".
@reutrn array The permission array.
public function permissions() {
$permissions = array();
$definition = $this
->getDefinition();
foreach ($this
->requestMethods() as $method) {
$lowered_method = strtolower($method);
// Only expose permissions where the HTTP request method exists on the
// plugin.
if (method_exists($this, $lowered_method)) {
$permissions["restful {$lowered_method} {$this->plugin_id}"] = array(
'title' => t('Access @method on %label resource', array(
'@method' => $method,
'%label' => $definition['label'],
)),
);
}
}
return $permissions;
}