I need to use the “-” character in my URLs, and have them map to controllers and controller functions - but of course I can’t use a “-” in my controller function names.
My main idea is to replace the "-" with a "_" when the URL is mapped to the controller/function. I know how to do this with the urlManager in the config file for distinct URLs, but I have 2 questions:
-
as only 2 controllers need this ability, is it possible for me to add code to the init function of a controller to parse the URL and replace the “-” with “_” so that the function can be reached? It seems expensive to parse every URL when I know most don’t need this conversion.
-
what is the most effective way to do this globally, if I need to - ie: where should I put the code and what should I use to do it: a built-in Yii parser to do the replacement, or a simple str_replace call?
Cheers,
Sean