You are here

public function EntityResource::availableMethods in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/rest/src/Plugin/rest/resource/EntityResource.php \Drupal\rest\Plugin\rest\resource\EntityResource::availableMethods()

Returns the available HTTP request methods on this plugin.

Return value

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

Overrides ResourceBase::availableMethods

1 method overrides EntityResource::availableMethods()
ContactMessageResource::availableMethods in core/modules/contact/src/Plugin/rest/resource/ContactMessageResource.php
Returns the available HTTP request methods on this plugin.

File

core/modules/rest/src/Plugin/rest/resource/EntityResource.php, line 409

Class

EntityResource
Represents entities as resources.

Namespace

Drupal\rest\Plugin\rest\resource

Code

public function availableMethods() {
  $methods = parent::availableMethods();
  if ($this
    ->isConfigEntityResource()) {

    // Currently only GET is supported for Config Entities.
    // @todo Remove when supported https://www.drupal.org/node/2300677
    $unsupported_methods = [
      'POST',
      'PUT',
      'DELETE',
      'PATCH',
    ];
    $methods = array_diff($methods, $unsupported_methods);
  }
  return $methods;
}