【发布时间】:2016-06-27 12:40:23
【问题描述】:
$this->getServiceContainer()->get('router')->getGenerator()->generate('ting_user_reset_password', array(), UrlGeneratorInterface::ABSOLUTE_URL);
当我尝试使用路由名称 ting_user_reset_password 生成带有 router 服务的 URL 时,会发生异常,因为使用 JMSI18nRoutingBundle 时,路由名称不存在。
/**
* @Route("/reset-password", name="ting_user_reset_password")
* @Template()
*/
public function resetPasswordAction(){
}
JMSI18nRoutingBundle 创建以下路由:
us_US_RG_ting_user_reset_password
de_DE_RG_ting_user_reset_password
es_ES_RG_ting_user_reset_password
...
如果您为此路由禁用 JMSI18nRoutingBundle,则路由器服务可以正常工作:
/**
* @Route("/reset-password", name="ting_user_reset_password", options={"i18n" = false})
* @Template()
*/
public function resetPasswordAction(){
}
如何通过指定路由名称使用路由服务获取URL?
谢谢。
【问题讨论】: