Here is a rather hackish snippet that might help you. Put this in your 
bootstrap.php:

--------------------------------------------------------------------------------------------------------
function listControllers($underscored = false) {
    uses('Folder');
    $Folder = new Folder();
   
    if ($underscored == false) {
        $toCtrlName = create_function('$controllerFile', 'return 
Inflector::camelize(r("_controller.php", "", $controllerFile));');
    } else {
        $toCtrlName = create_function('$controllerFile', 'return 
r("_controller.php", "", $controllerFile);');
    }
   
    $Configure = Configure::getInstance();
    foreach($Configure->controllerPaths as $path) {
        $Folder->cd($path);
        $controllerFiles = $Folder->find('.+_controller\.php$');
        $controllers = array_map($toCtrlName, $controllerFiles);
    }
   
    return $controllers;
}
--------------------------------------------------------------------------------------------------------

Then you can use it in your routes.php to get a nice regex strings 
matching all your controllers like this:

--------------------------------------------------------------------------------------------------------
$controllerRegex = '('.join('|', array_map('preg_quote', 
listControllers(true))).')';
--------------------------------------------------------------------------------------------------------

This should be very useful if you decide to manually map all controllers 
by yourself.

HTH, Felix
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de


John David Anderson (_psychic_) wrote:
> On May 24, 2007, at 10:19 AM, Greg wrote:
>
>   
>>> Can you take a step back and explain why you need the route, and
>>> maybe provide some examples? Maybe we can find a good way to do what
>>> you want.
>>>       
>> We need to have a url schema like http://domain.com/community/ 
>> category/post,
>> so I have defined routes accordingly.  These routes work great, except
>> that they completely override cake's default routes.  Now, simple
>> commands like requestAction(/controller/action/...) are confused with
>> these routes, rather than using cake's defaults.
>>     
>
> Would you be amenable to changing the URL format a bit? You just need  
> a way to distinguish a community name from a controller name.
>
> Something like these might be matchable using regex to avoid  
> controller name collisions:
>
> http://example.com/c:los_angeles/computers/mac_rulez
> http://example.com/los_angeles:computers/mac_rulez
> http://example.com/c_los_angeles/computers/mac_rulez
>
> Just add some little marker in there that regex can pick up and  
> recognize as a community name.
>
> Its a little hacky, but you could also iterate through your  
> controllers directory and grab out the names and add those as  
> conditions in the regex. The CONTROLLERS constant is your friend  
> there. I think that this approach is less user-friendly, as some sort  
> of marker in the URL to denote community names is more user-friendly.
>
> -- John
>
> >
>
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to