diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php index 1bd1d8dee9..c432c5bf2c 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php @@ -22,6 +22,7 @@ * }, * "access" = "Drupal\config_test\ConfigTestAccessControlHandler" * }, + * rest_resource = TRUE, * config_prefix = "dynamic", * entity_keys = { * "id" = "id", diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 9111fafccc..8cf6cb236a 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -390,6 +390,20 @@ protected function getBaseRoute($canonical_path, $method) { } /** + * {@inheritdoc} + */ + public function availableMethods() { + $methods = parent::availableMethods(); + if ($this->isConfigEntityResource() && !empty($this->entityType->get('rest_resource'))) { + // 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; + } + + /** * Checks if this resource is for a Config Entity. * * @return bool