Issue #1874820 by klausi: Resource plugins miss an interface.
parent
b45a343e39
commit
db63357956
|
@ -14,17 +14,14 @@ use Symfony\Component\Routing\RouteCollection;
|
|||
/**
|
||||
* Common base class for resource plugins.
|
||||
*/
|
||||
abstract class ResourceBase extends PluginBase {
|
||||
abstract class ResourceBase extends PluginBase implements ResourceInterface {
|
||||
|
||||
/**
|
||||
* Provides an array of permissions suitable for hook_permission().
|
||||
* 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".
|
||||
*
|
||||
* @reutrn array
|
||||
* The permission array.
|
||||
*/
|
||||
public function permissions() {
|
||||
$permissions = array();
|
||||
|
@ -43,13 +40,7 @@ abstract class ResourceBase extends PluginBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of routes with URL path information for the resource.
|
||||
*
|
||||
* This method determines where a resource is reachable, what path
|
||||
* replacements are used, the required HTTP method for the operation etc.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\RouteCollection
|
||||
* A collection of routes that should be registered for this resource.
|
||||
* Implements ResourceInterface::routes().
|
||||
*/
|
||||
public function routes() {
|
||||
$collection = new RouteCollection();
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\rest\Plugin\ResourceInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\rest\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
|
||||
/**
|
||||
* Specifies the publicly available methods of a resource plugin.
|
||||
*/
|
||||
interface ResourceInterface extends PluginInspectionInterface {
|
||||
|
||||
/**
|
||||
* Returns a collection of routes with URL path information for the resource.
|
||||
*
|
||||
* This method determines where a resource is reachable, what path
|
||||
* replacements are used, the required HTTP method for the operation etc.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\RouteCollection
|
||||
* A collection of routes that should be registered for this resource.
|
||||
*/
|
||||
public function routes();
|
||||
|
||||
/**
|
||||
* Provides an array of permissions suitable for hook_permission().
|
||||
*
|
||||
* A resource plugin can define a set of user permissions that are used on the
|
||||
* routes for this resource or for other purposes.
|
||||
*
|
||||
* @return array
|
||||
* The permission array.
|
||||
*/
|
||||
public function permissions();
|
||||
|
||||
}
|
Loading…
Reference in New Issue