Commit 1c408b7c authored by webchick's avatar webchick
Browse files

Issue #1909170 by klausi, moshe weitzman: REST write operations should log a watchdog message.

parent 8ad7708b
......@@ -76,6 +76,8 @@ public function post($id, EntityInterface $entity) {
}
try {
$entity->save();
watchdog('rest', 'Created entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
$url = url(strtr($this->plugin_id, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE));
// 201 Created responses have an empty body.
return new ResourceResponse(NULL, 201, array('Location' => $url));
......@@ -114,6 +116,8 @@ public function put($id, EntityInterface $entity) {
$entity->{$info['entity_keys']['id']} = $id;
try {
$entity->save();
watchdog('rest', 'Updated entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
// Update responses have an empty body.
return new ResourceResponse(NULL, 204);
}
......@@ -157,6 +161,8 @@ public function patch($id, EntityInterface $entity) {
}
try {
$original_entity->save();
watchdog('rest', 'Updated entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
// Update responses have an empty body.
return new ResourceResponse(NULL, 204);
}
......@@ -182,6 +188,8 @@ public function delete($id) {
if ($entity) {
try {
$entity->delete();
watchdog('rest', 'Deleted entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
// Delete responses have an empty body.
return new ResourceResponse(NULL, 204);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment