I have the following route, and generate_shortest_url is true:
test:
url: /text/:optional
param: { optional: ~ }
I works like a charm for matchesUrl() - the URL "/text" gets correctly routed to the default module and action. However it fails in matchesParameters() unless the "optional" parameter is specified. For example:
var_dump($this->getController()->genUrl(array()));
- does not return "/text"
I think this is because in sfRoute.class.php:153, symfony filters all null or empty parameters, including optional parameters. I wish if generate_shortest_url is true and the parameter is optional, symfony would not filter it. This should enable the following behavior from my route:
- genUrl(array()) => "/text"
- matchesUrl("/text") => array('module' => 'default', 'action' => 'index', 'optional' => null);
- genUrl(array('optional' => 'foo')) => /text/foo
- matchesUrl("/text/foo") => array('module' => 'default', 'action' => 'index', 'optional' => 'foo');