我必须在任务中生成一个 URL,但我得到的 URL 类型不正确:
./symfony/user/edit/id
当我需要的时候
/user/edit/id
我的第一次尝试是:
protected function execute($arguments = array(), $options = array())
{
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
$this->context = sfContext::createInstance($configuration);
$baseurl = $this->context->getController()->genUrl(array('module' => 'user','action' => 'edit', 'id' => $id));
// ...
}
我的第二次尝试,按照这个答案给出了相同的错误网址:
protected function execute($arguments = array(), $options = array())
{
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
$this->context = sfContext::createInstance($configuration);
$routing = $this->context->getRouting();
$baseurl = $routing->generate('user_edit', array('id' => $id));
// ...
}
我怎样才能得到正确的网址?