「ドット」以外の形式を前に付けるFOSRestBundleメソッドでルートを定義できるかどうか疑問に思っています。
たとえば、次の機能が必要だとします。
http://somesite.com/api/user/20 (renders in the default/fallback format)
http://somesite.com/api/user/20/json (renders in JSON)
http://somesite.com/api/user/20/xml (renders in XML)
次のようなルートを定義しようとすると、次のようになります。
/**
* @Get("/user/{id}/{_format}
*/
public function getUserAction($id)
{
// do stuff
}
私はこれを手に入れます:
Route pattern "/api/users/{maximum}/{_format}.{_format}" cannot reference variable name "_format" more than once.
それは私に気づきました-そしてそれによって、私たちはデフォルトでSymfony2ではなくFOSRestBundleを話していると思います-私が定義するルートの最後に「。{_format}」を自動的に追加します。私はびっくりしました!
したがって、今のところ、私の前の例では、次のように機能します。
http://somesite.com/api/user/20 (renders in the default/fallback format)
http://somesite.com/api/user/20.json (renders in JSON)
http://somesite.com/api/user/20.xml (renders in XML)
確かに小さな違いですが、私はこの構文を使用するレガシーアプリを移植しようとしています。私がやろうとしていることは可能ですか?その場合、各ルートへの「。{_ format}」の自動追加を無効にするにはどうすればよいですか?
ありがとう!