You are here

public function ResourceBase::availableMethods 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::availableMethods()

Returns the available HTTP request methods on this plugin.

Return value

array The list of supported methods. Example: array('GET', 'POST', 'PATCH').

Overrides ResourceInterface::availableMethods

2 calls to ResourceBase::availableMethods()
ResourceBase::permissions in core/modules/rest/src/Plugin/ResourceBase.php
Implements ResourceInterface::permissions().
ResourceBase::routes in core/modules/rest/src/Plugin/ResourceBase.php
Returns a collection of routes with URL path information for the resource.

File

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

Class

ResourceBase
Common base class for resource plugins.

Namespace

Drupal\rest\Plugin

Code

public function availableMethods() {
  $methods = $this
    ->requestMethods();
  $available = array();
  foreach ($methods as $method) {

    // Only expose methods where the HTTP request method exists on the plugin.
    if (method_exists($this, strtolower($method))) {
      $available[] = $method;
    }
  }
  return $available;
}