summaryrefslogtreecommitdiffstats
path: root/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-02-09 21:45:33 +0900
committerNathaniel Catchpole2016-02-09 21:45:33 +0900
commite50aac4765a35a6234d72e361f0156f4e69b5ae6 (patch)
treecb1dc36dd25c968446279bfcdf12a6ac6a829649 /core/modules/rest/src/Plugin/rest/resource/EntityResource.php
parenta19c7b6a39f4cbdf17dbae3ba67532b8f23e8b8e (diff)
Issue #2546216 by fortis, edutrul, -enzo-: Return entity object in REST response body after successful POST
Diffstat (limited to 'core/modules/rest/src/Plugin/rest/resource/EntityResource.php')
-rw-r--r--core/modules/rest/src/Plugin/rest/resource/EntityResource.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
index d906417..a2d712d 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php
@@ -107,9 +107,10 @@ class EntityResource extends ResourceBase {
$entity->save();
$this->logger->notice('Created entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
- // 201 Created responses have an empty body.
+ // 201 Created responses return the newly created entity in the response
+ // body.
$url = $entity->urlInfo('canonical', ['absolute' => TRUE])->toString(TRUE);
- $response = new ResourceResponse(NULL, 201, ['Location' => $url->getGeneratedUrl()]);
+ $response = new ResourceResponse($entity, 201, ['Location' => $url->getGeneratedUrl()]);
$response->addCacheableDependency($url);
return $response;
}