基于此示例: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".)
答案 0 :(得分:5)
我依稀记得链接到包含这些资源的文件的资源需要是rest类型(因此你的VSmartRestUserBundle链接:app / config / routing.yml中的路由资源需要具有rest类型)。
我可能错了,但我并没有真正使用父功能。
事实上,它是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"