【发布时间】:2011-11-17 17:52:11
【问题描述】:
我在app/vendors/shells 中有一个脚本,它通过 cron 定期执行。在该脚本中,我导入了 Router:
class AutosuggestFileShell extends Shell {
var $uses = array('User','Country','City','Speciality','Alias');
function main() {
App::import('Core', 'Router');
//...
但是脚本没有使用我在routes.php 中定义的路由。例如,我定义了:
Router::connect('/plastic-surgeon/*', array(
'controller' => 'users', 'action' => 'profile'
));
但在脚本中的这一行:
'path' => Router::url(array(
'controller' => 'users', 'action' => 'profile', $user['User']['slug']
))
不生成 URL plastic-surgeon/slug - 而是生成 URL users/profile/slug。
Router::url() 在网站的不同位置都能正常工作,例如在视图内生成站点地图。因此我想我需要从 shell 脚本中导入一些东西,或者可能无法从 shell 脚本中加载 routes.php 中包含的数据?
(我使用的是 CakePHP 1.3)
【问题讨论】:
标签: shell cakephp cakephp-1.3