automagically made it the double reference to plugins/controllers
disappear. Ie. /admin/projects/projects/view/1 was automagically /
admin/projects/view/1.
So I've been trying to get it back for like a week now, and have it
pretty well done, but something very strange is going on and I was
wondering if anyone might have some ideas to push me in another
direction.
Situation Summary : Routing works in most cases, but if debug mode is
off (ie. set it to 0 in core.php) after a new repository publish
almost no pages work until I turn on debug mode (set to 2) and refresh
almost exactly 3 times. After that it works with debug mode set back
to zero. So its obviously some caching issue, but boy is it annoying
to be working on a project for the first time since publishing a repo
commit and save some changes and have all of those changes be lost
because I didn't run the "add" function three times in full debug mode
to update the cache.
Routing Code :
# shorten up plugin urls
$controllerKey = false;
$prefixedPluginKey = false;
$urlPieces = explode('/', $fromUrl);
$plugins = App::objects('plugin');
$pluginKey = array_search(Inflector::camelize($urlPieces[0]),
$plugins);
if (!empty($urlPieces[1])) $prefixedPluginKey =
array_search(Inflector::camelize($urlPieces[1]), $plugins);
# lets do non-admin or prefixed first
if ($pluginKey !== false) {
# and check if the next url piece is a controller or an action or if
it even exists
$plugin = strtolower($plugins[$pluginKey]);
if (!empty($urlPieces[0])) {
$pluginPath = App::pluginPath($plugin);
$controllers = App::objects('controller',
$pluginPath.'controllers');
$controllerKey = array_search(Inflector::camelize($urlPieces[1]),
$controllers);
if ($controllerKey !== false) {
$controller = $controllers[$controllerKey];
Router::Connect('/'.$plugin.'/:controller/:action/*',
array('plugin' => $plugin, 'controller' => $controller));
} else {
$controller = $plugin;
Router::Connect('/'.$plugin.'/:action/*', array('plugin' =>
$plugin, 'controller' => $controller));
}
}
} else if ($prefixedPluginKey !== false) {
# now lets do admin
$plugin = strtolower($plugins[$prefixedPluginKey]);
if ($urlPieces[0] == 'admin') {
$pluginPath = App::pluginPath($plugin);
$controllers = App::objects('controller',
$pluginPath.'controllers');
if(!empty($urlPieces[2])) $controllerKey =
array_search(Inflector::camelize($urlPieces[2]), $controllers);
if ($controllerKey !== false) {
$controller = $controllers[$controllerKey];
Router::Connect('/admin/'.$plugin.'/:controller/:action/*',
array('plugin' => $plugin, 'controller' => $controller, 'admin'=>
true));
} else {
$controller = $plugin;
Router::Connect('/admin/'.$plugin.'/:action/*', array('plugin' =>
$plugin, 'controller' => $controller, 'admin'=> true));
}
}
}
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment