Re: Adding new routes from a controller. (Cake 1.2)

2007-12-07 Thread Chris Hawes

Ok, I've cracked it, I have put the code in the applications app/
config/routes.php file. The code is as follows:

$Configure =& Configure::getInstance();
$Folder =& new Folder();

$Folder->cd($Configure->pluginPaths[0]);
$plugins = $Folder->ls();

foreach ($plugins[0] as $plugin) {
$File =& new File($Configure->pluginPaths[0] . $plugin . DS .
'config' . DS . $plugin . '_routes.php');

if ($File->exists()) {
include_once($File->pwd());
}
}

Ta,

Chris.


On Dec 7, 6:42 pm, Chris Hawes <[EMAIL PROTECTED]> wrote:
> Hello,
>
> The application I am currently developing will make the use of
> plugins.
>
> Currently in the app/app_controller.php beforeFilter (which is
> probably the wrong place) I get a list of plugins. I then check to see
> if a config file exists for the plugin, and execute the file.
>
> I would also like to allow the plugin to define routes (could be
> dangerous I know).
>
> Should I include a custom file in bootstrap.php and from there load in
> the various plugins routes?  Can I use the nice File and Folder
> classes from a file loaded with bootstrap.php?
>
> The long and short of it is, how do I define more routes in a
> controller? Is there a better way of doing this?
>
> Sorry if this isn't clear, or if I'm horribly breaking the MVC way.
>
> Many Thanks,
>
> Chris.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Adding new routes from a controller. (Cake 1.2)

2007-12-07 Thread Chris Hawes

Hello,

The application I am currently developing will make the use of
plugins.

Currently in the app/app_controller.php beforeFilter (which is
probably the wrong place) I get a list of plugins. I then check to see
if a config file exists for the plugin, and execute the file.

I would also like to allow the plugin to define routes (could be
dangerous I know).

Should I include a custom file in bootstrap.php and from there load in
the various plugins routes?  Can I use the nice File and Folder
classes from a file loaded with bootstrap.php?

The long and short of it is, how do I define more routes in a
controller? Is there a better way of doing this?

Sorry if this isn't clear, or if I'm horribly breaking the MVC way.

Many Thanks,

Chris.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---