ResourceInterface.php 1.51 KB
Newer Older
1 2 3 4 5 6 7 8
<?php

namespace Drupal\rest\Plugin;

use Drupal\Component\Plugin\PluginInspectionInterface;

/**
 * Specifies the publicly available methods of a resource plugin.
9 10 11 12 13
 *
 * @see \Drupal\rest\Annotation\RestResource
 * @see \Drupal\rest\Plugin\Type\ResourcePluginManager
 * @see \Drupal\rest\Plugin\ResourceBase
 * @see plugin_api
14 15
 *
 * @ingroup third_party
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 */
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();

  /**
31
   * Provides an array of permissions suitable for .permissions.yml files.
32 33 34 35
   *
   * A resource plugin can define a set of user permissions that are used on the
   * routes for this resource or for other purposes.
   *
36 37 38 39
   * It is not required for a resource plugin to specify permissions: if they
   * have their own access control mechanism, they can use that, and return the
   * empty array.
   *
40 41 42 43 44
   * @return array
   *   The permission array.
   */
  public function permissions();

45 46 47 48 49 50 51 52
  /**
   * Returns the available HTTP request methods on this plugin.
   *
   * @return array
   *   The list of supported methods. Example: array('GET', 'POST', 'PATCH').
   */
  public function availableMethods();

53
}