How to define default date values in Symfony2 routes?

前端 未结 2 828
无人共我
无人共我 2021-01-14 00:24

If I want to create a route, where the year, month and date are variables, how can I define that if these variables are empty, the current date shall be taken?

E.g.

2条回答
  •  有刺的猬
    2021-01-14 00:34

    You can set $year = null, $month = null, $day = null in controller.

    or maybe in route:

    year:  null,
    month: null,
    day:   null,
    

    Then in controller you should get last posts if variables = null, or posts by date.

提交回复
热议问题