2014-07-23 79 views
2

基於此示例:http://npmasters.com/2012/11/25/Symfony2-Rest-FOSRestBundle.html父屬性是不允許的

我試圖在FOSRestBundle實現中使用父項。但問題在於,似乎父屬性不再被識別或不被支持。有任何建議嗎?

bla_rest_api_Location: 
    type: rest 
    parent: bla_rest_api_User 
    resource: Bla\RestUserBundle\Controller\LocationController 

例外:

[Symfony\Component\Config\Exception\FileLoaderLoadException] 
Cannot import resource "C:\xampp\htdocs\EntisServer\src\VSmart\RestUserBund 
le/Resources/config/routing.yml" from "C:/xampp/htdocs/EntisServer/app/conf 
ig\routing.yml". (The routing file "C:\xampp\htdocs\EntisServer\src\VSmart\ 
RestUserBundle/Resources/config/routing_generated.yml" contains unsupported 
    keys for "v_smart_rest_api_Location": "parent". Expected one of: "resource 
", "type", "prefix", "pattern", "path", "host", "schemes", "methods", "defa 
ults", "requirements", "options", "condition".) 

回答

5

我依稀記得一些關於資源鏈接到包含這些資源需要的類型爲休息(這樣的鏈接你的VSmartRestUserBundle的文件:在app /配置路由資源/routing.yml將需要類型休息)。

雖然我可能是錯的,但我沒有真正使用父功能。

實際上它是here

Notice parent: users option in the second case. 
This option specifies that the comments resource is child of the users resource. 

It is also necessary to add type: rest to the routing.yml file: 

# app/config/routing.yml 
acme_hello: 
    type: rest 
    resource: "@AcmeHelloBundle/Resources/config/users_routes.yml" 
+0

Dit將'type'休息添加到主include,但必須在路由之間進行。 –