.../rest/src/Plugin/rest/resource/EntityResource.php | 13 +------------ .../Functional/EntityResource/EntityResourceTestBase.php | 9 ++++----- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 834c2bb..612deff 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -394,9 +394,8 @@ protected function getBaseRoute($canonical_path, $method) { */ public function availableMethods() { $methods = parent::availableMethods(); + // Without validation, it's impossible to support creation or modification. if (!$this->entityType->get('supports_validation')) { - // 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); } @@ -404,16 +403,6 @@ public function availableMethods() { } /** - * Checks if this resource is for a Config Entity. - * - * @return bool - * TRUE if the entity is a Config Entity, FALSE otherwise. - */ - protected function isConfigEntityResource() { - return $this->entityType instanceof ConfigEntityType; - } - - /** * {@inheritdoc} */ public function calculateDependencies() { diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 5b22991..5e32a7e 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -631,7 +631,7 @@ protected static function castToString(array $normalization) { public function testPost() { // @todo Remove this in https://www.drupal.org/node/2300677. if (!$this->entity->getEntityType()->get('supports_validation')) { - $this->assertTrue(TRUE, "This entity type doesn't support posting."); + $this->assertTrue(TRUE, "This entity type doesn't support POSTing."); return; } @@ -738,7 +738,6 @@ public function testPost() { // DX: 422 when invalid entity: multiple values sent for single-value field. $response = $this->request('POST', $url, $request_options); - if ($this->entity instanceof ConfigEntityInterface) { $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nlabel: This value should be of the correct primitive type.\n", $response); } @@ -748,6 +747,7 @@ public function testPost() { $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\n$label_field: $label_field_capitalized: this field cannot hold more than 1 values.\n", $response); } + $request_options[RequestOptions::BODY] = $parseable_invalid_request_body_2; @@ -840,7 +840,7 @@ public function testPost() { */ public function testPatch() { if (!$this->entity->getEntityType()->get('supports_validation')) { - $this->assertTrue(TRUE, "This entity type doesn't support patching."); + $this->assertTrue(TRUE, "This entity type doesn't support PATCHing."); return; } @@ -1040,7 +1040,7 @@ public function testPatch() { */ public function testDelete() { if (!$this->entity->getEntityType()->get('supports_validation')) { - $this->assertTrue(TRUE, "This entity type doesn't support deletion."); + $this->assertTrue(TRUE, "This entity type doesn't support DELETEing."); return; } @@ -1213,7 +1213,6 @@ protected function getEntityResourcePostUrl() { protected function makeNormalizationInvalid(array $normalization) { // Add a second label to this entity to make it invalid. $label_field = $this->entity->getEntityType()->hasKey('label') ? $this->entity->getEntityType()->getKey('label') : static::$labelFieldName; - if ($this->entity instanceof FieldableEntityInterface) { $normalization[$label_field][1]['value'] = 'Second Title'; }