在我的 Symfony2 应用程序中,我想通过一条路线使四个 url 成为可能:
- 很多其他东西/报告/-20 (负数)
- a-lot-of-other-stuff/report/40 (正数)
- 很多其他的东西/报告/ (没有数字)
- 很多其他的东西/报告(没有数字和没有 / )
我的路线目前看起来像这样:
report:
pattern: /report/{days}
defaults: { _controller: "AppReportBundle:Report:dayReport", days = null }
动作定义为:
public function dayReportAction($days = null)
{
// my code here
}
这目前使 url 1 和 2 工作,但在 url 3 和 4 的情况下,我得到一个错误
找不到路线
如何使参数“days”可选?
如果没有提供参数,我怎么能允许/
省略呢?