【发布时间】:2010-07-19 23:37:10
【问题描述】:
我在 Ubuntu 10.0.4 LTS 上运行 Symfony 1.3.6。
我编写了一个 Symfony 任务,它生成一个包含链接(URL)的报告。
这是我的任务类中 execute() 方法的 sn-p:
protected function execute($arguments = array(), $options = array())
{
//create a context
sfContext::createInstance($this->configuration);
sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'Asset', 'Tag'));
...
$url = url_for("@foobar?cow=marymoo&id=42");
// Line 1
echo '<a href="'.$url.'">This is a test</a>';
// Line 2
echo link_to('This is a test', $url);
}
路由名称是这样定义的:
foobar:
url: /some/fancy/path/:cow/:id/hello.html
param: { module: mymodule, action: myaction }
运行时,生成的链接是:
第 1 行 产生以下输出:
./symfony/symfony/some/fancy/path/marymoo/42/hello.html
而不是预期的:
/some/fancy/path/marymoo/42/hello.html
第 2 行生成错误:
找不到匹配的路由到 为参数“数组( '动作' => 'symfony', '模块' => '.',)"。
同样,预期的 URL 是:
/some/fancy/path/marymoo/42/hello.html
我该如何解决这个问题?
【问题讨论】:
标签: symfony1 symfony-1.4