Jeffrey Sambells wrote:
$clone = clone $router->getRoute( 'example' );
$clone->setRoute( '/example2/:id' );
$router->addRoute( 'example2', $clone );
Which would result in /example/:id and /example2/:id going to the same
action using identical defaults and requirements.
Or just altering it after the fact without clone:
$router->getRoute( 'example' )->setRoute( '/example2/:id' )-
>setDefault( ':id', 'some-other-id' );
The set methods don't exist on the existing route object and I know I
could make my own route object to do this but is there an underlying
technological reason they're not already there?
This would complicate the route objects which should be as lightweight as possible as
you will have lots of them on sophisticated systems.
Basically you would probably need to reset parameters and do some of the __construct
job. If the route is matched you would need the parameters (defaults, requirements) to
be dropped because they possibly wouldn't make sense in a new route path.
The route objects are immutable now so you don't have to care about what happens between
match() and assemble(). If they are allowed to be changed mid request you get another
concern.
I guess the easiest way to get similar functionality would be to allow getting
requirements out of the standard route, so you could keep immutability and do:
$r = $router->getRoute('example');
$new = new Zend_C_R_Route('/example2/:id', $r->getDefaults(),
$r->getRequirements());
$router->addRoute('example2', $new);
But it means more work for you as different types of routes have different construct
parameters. If it's sufficient for you, please create a Jira issue and assign it to me,
Jeffrey.
--
Michał Minicki aka Martel Valgoerad | [EMAIL PROTECTED] |
http://aie.pl/martel.asc
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Idleness is not doing nothing. Idleness is being free to do anything." --
Floyd Dell