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

Commit 7181de8

Browse files
committed
Serialize children
1 parent c52fe3e commit 7181de8

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Serializer/Handler/ResourceCollectionHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function serializeCollection(
5151
) {
5252
$res = array();
5353
foreach ($collection as $resource) {
54+
$context->startVisiting($resource);
5455
$res[$resource->getName()] = $context->accept($resource);
56+
$context->stopVisiting($resource);
5557
}
5658

5759
return $res;

Tests/Features/resource_api_decorator.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Feature: Resource enhancement
1717
-
1818
repository: phpcr_repo
1919
enhancer: payload
20-
2120
"""
2221

2322

Tests/Features/resource_api_phpcr_odm.feature

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feature: PHPCR-ODM resource repository
2020
"""
2121

2222

23-
Scenario: Retrieve a PHPCR-ODM resource with children
23+
Scenario: Retrieve a PHPCR-ODM resource
2424
Given there exists a "Article" document at "/cmf/articles/foo":
2525
| title | Article 1 |
2626
| body | This is my article |
@@ -39,3 +39,32 @@ Feature: PHPCR-ODM resource repository
3939
"children": []
4040
}
4141
"""
42+
43+
Scenario: Retrieve a PHPCR-ODM resource with children
44+
Given there exists a "Article" document at "/cmf/articles/foo":
45+
| title | Article 1 |
46+
| body | This is my article |
47+
And there exists a "Article" document at "/cmf/articles/foo/bar":
48+
| title | Article child |
49+
| body | There are many like it |
50+
And there exists a "Article" document at "/cmf/articles/foo/boo":
51+
| title | Article child |
52+
| body | But this one is mine |
53+
Then I send a GET request to "/api/phpcrodm_repo/foo"
54+
And print response
55+
And the response code should be 200
56+
And the response should contain json:
57+
"""
58+
{
59+
"repository_alias": "phpcrodm_repo",
60+
"repository_type": "doctrine_phpcr_odm",
61+
"payload_alias": "article",
62+
"payload_type": "Symfony\\Cmf\\Bundle\\ResourceRestBundle\\Tests\\Resources\\TestBundle\\Document\\Article",
63+
"path": "\/foo",
64+
"repository_path": "\/foo",
65+
"children": {
66+
"bar": null,
67+
"boo": null
68+
}
69+
}
70+
"""

0 commit comments

Comments
 (0)