Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit dcd405e

Browse files
authored
Merge pull request #46 from symfony-cmf/patch-return-new-document
Return the new document after PATCH has finished
2 parents 918a560 + e419860 commit dcd405e

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/Controller/ResourceController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,17 @@ public function patchResourceAction($repositoryName, $path, Request $request)
133133
$targetPath = $action['target'];
134134
$repository->move($path, $targetPath);
135135

136+
$resource = $repository->get($targetPath);
137+
136138
break;
137139
default:
138-
return $this->badRequestResponse(sprintf('Only operation "%s" is not supported, supported operations: move.', $action['operation']));
140+
return $this->badRequestResponse(sprintf('Operation "%s" is not supported, supported operations: move.', $action['operation']));
139141
}
140142
}
141143

142-
return $this->createResponse('', Response::HTTP_NO_CONTENT);
144+
$this->resourceHandler->setMaxDepth(0);
145+
146+
return $this->createResponse($resource, Response::HTTP_OK);
143147
}
144148

145149
/**

tests/Features/resource_api_phpcr.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Feature: PHPCR resource repository
4949
"""
5050
[{"operation": "move", "target": "/foo-bar"}]
5151
"""
52-
Then the response code should be 204
52+
Then the response code should be 200
5353
And there is an "Article" document at "/cmf/articles/foo-bar"
5454
| title | Article 1 |
5555
| body | This is my article |
@@ -65,7 +65,7 @@ Feature: PHPCR resource repository
6565
"""
6666
[{"operation": "move", "target": "/bar/foo"}]
6767
"""
68-
Then the response code should be 204
68+
Then the response code should be 200
6969
And there is an "Article" document at "/cmf/articles/bar/foo"
7070
| title | Article 1 |
7171
| body | This is my article |

tests/Features/resource_api_phpcr_odm.feature

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Feature: PHPCR-ODM resource repository
108108
"""
109109
[{"operation": "move", "target": "/foo-bar"}]
110110
"""
111-
Then the response code should be 204
111+
Then the response code should be 200
112112
And there is an "Article" document at "/cmf/articles/foo-bar":
113113
| title | Article 1 |
114114
| body | This is my article |
@@ -124,7 +124,21 @@ Feature: PHPCR-ODM resource repository
124124
"""
125125
[{"operation": "move", "target": "/bar/foo"}]
126126
"""
127-
Then the response code should be 204
127+
Then the response code should be 200
128+
And the response should contain json:
129+
"""
130+
{
131+
"repository_alias": "phpcrodm_repo",
132+
"repository_type": "doctrine/phpcr-odm",
133+
"payload_alias": "article",
134+
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
135+
"path": "\/bar\/foo",
136+
"node_name": "foo",
137+
"label": "foo",
138+
"repository_path": "\/bar\/foo",
139+
"children": []
140+
}
141+
"""
128142
And there is an "Article" document at "/cmf/articles/bar/foo":
129143
| title | Article 1 |
130144
| body | This is my article |

0 commit comments

Comments
 (0)