我在 Ubuntu 10.0.4 LTS 上运行Symfony 1.3.6。
我编写了一个 Symfony 任务,它生成一个包含链接(URL)的报告。
execute()
这是我的任务类中的方法片段:
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 行生成错误:
找不到匹配的路由来为参数“array ('action' => 'symfony', 'module' => '.',)”生成 url。
同样,预期的 URL 是:
/some/fancy/path/marymoo/42/hello.html
我该如何解决这个问题?