有没有办法获取 URL 引用的模块/操作?
在 symfony 中,是否有一种方法可以使用它对我的路由进行反向查找以确定 URL 指向的模块和操作?
比如说:
get_module("http://host/cars/list"); // ("cars")
get_action("http://host/frontend_dev.php/cars/list"); // ("list")
请记住,我不想执行简单的字符串黑客来执行此操作,因为可能存在不太明显的映射:
get_module("/"); // (What this returns is entirely dependent on the configured routes.)
谢谢!
In symfony, is there a method that I can use which does a reverse lookup on my routes to determine the module and action a URL points to?
Say, something like:
get_module("http://host/cars/list"); // ("cars")
get_action("http://host/frontend_dev.php/cars/list"); // ("list")
Bear in mind, I don't want to perform simple string-hacking to do this as there may be mappings that are not quite so obvious:
get_module("/"); // (What this returns is entirely dependent on the configured routes.)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 sfRouting 类来匹配 URL。这是 sfContext 对象的一部分。您的代码(在操作中)将如下所示:
Use the sfRouting class to match URLs. This is part of the sfContext object. Your code (in an action) would look like this: