Attached are ModuleDispatcher and BaseDispatcher which are extensions to MultiURLDispatcher and URLDispatcher respectively.
The generate_url() functions probably work as expected. $mymultiurldispatcher->generate_url('mymodule', 'mycommand', array('id' => 5)) returns $mydispatcher->generate_url('mycommand, array('id' => 5)) prefixed with the prefix for 'mymodule', where $mydispatcher is an instance of the class which is mapped to 'mymodule'.
$mydispatcher->generate_url('mycommand, array('id' => 5)) returns an url part for the first mapping with command 'mycommand' and if it contains and ':id' part it will be substituted by 5. It returns a trailing slash depending on the 'force-trailing-slash' option.
I expect that this code can quite safely be inserted in the original MultiURLDispatcher and URLDispatcher classes. Only note that on line 50 the line
$dispatcher = BaseDispatcher::get_instance($class_name);
must be replaced with:
$dispatcher = URLDispatcher::get_instance($class_name);
KNOWN BUGS:
- When you want to generate the url of a certain module, the dispatcher for that module must be loaded.
- When you have multiple mappings to the same command name, the first one found will be used, regardless of possible different arguments.
- The arguments to the urls are not checked for existance.
i.e.: /item/:id/ will be resolved to '/item/'.$params['id'].'/' regardless of whether $params['id'] actually is set.
This code is largely obsoleted by the new AnewtURLDispatcher class which has a totally different API and structure (much better, imho, though). The feature request this bug is about still stands, though. I'm just not sure about a clean API for this.
Attached are ModuleDispatcher and BaseDispatcher which are extensions to MultiURLDispatcher and URLDispatcher respectively.
The generate_url() functions probably work as expected. $mymultiurldisp atcher- >generate_ url('mymodule' , 'mycommand', array('id' => 5)) returns $mydispatcher- >generate_ url('mycommand, array('id' => 5)) prefixed with the prefix for 'mymodule', where $mydispatcher is an instance of the class which is mapped to 'mymodule'. >generate_ url('mycommand, array('id' => 5)) returns an url part for the first mapping with command 'mycommand' and if it contains and ':id' part it will be substituted by 5. It returns a trailing slash depending on the 'force- trailing- slash' option.
$mydispatcher-
I expect that this code can quite safely be inserted in the original MultiURLDispatcher and URLDispatcher classes. Only note that on line 50 the line :get_instance( $class_ name); :get_instance( $class_ name);
$dispatcher = BaseDispatcher:
must be replaced with:
$dispatcher = URLDispatcher:
KNOWN BUGS: '.$params[ 'id'].' /' regardless of whether $params['id'] actually is set.
- When you want to generate the url of a certain module, the dispatcher for that module must be loaded.
- When you have multiple mappings to the same command name, the first one found will be used, regardless of possible different arguments.
- The arguments to the urls are not checked for existance.
i.e.: /item/:id/ will be resolved to '/item/