If I want to create a route where the year, month, and date are variables, how can I determine if these variables are empty, should the current date be taken?
eg. like this (doesn't work for sure ...)
blog: path: /blog/{year}/{month}/{day} defaults: { _controller: AcmeBlogBundle:Blog:index, year: current_year, month: current_month day: current_day }
I was thinking of defining two different routes, such as
blog_current_day: path: /blog defaults: { _controller: AcmeBlogBundle:Blog:index } blog: path: /blog/{year}/{month}/{day} defaults: { _controller: AcmeBlogBundle:Blog:index }
But if I then call blog_current_day
my controller
public function indexAction(Request $request, $year, $month, $day) {
will throw an exception because there is no year, month, and day.
Any suggestions?
source share