I have a script in app/vendors/shells which is executed periodically via cron. In that script I import the Router:
class AutosuggestFileShell extends Shell {
var $uses = array('User','Country','City','Speciality','Alias');
function main() {
App::import('Core', 'Router');
//...
But the script is not using the routes I have defined in routes.php. For example, I have defined:
Router::connect('/plastic-surgeon/*', array(
'controller' => 'users', 'action' => 'profile'
));
But in the script the line:
'path' => Router::url(array(
'controller' => 'users', 'action' => 'profile', $user['User']['slug']
))
is not generating the URL plastic-surgeon/slug – instead it generates the URL users/profile/slug.
Router::url() works fine in different points of the website, for example inside a view to generate a sitemap. Therefore I guess I need to import something from the shell script or maybe it is not possible to load the data contained in routes.php from the shell script?
(I’m using CakePHP 1.3)
IF you want to import the routes try