[英]Symfony3 - Logout path generation method
在Symfony应用程序中使用path('logout')
和logout_path()
有什么区别?
When you use path('logout')
you call RoutingExtension::getPath
. 当您使用path('logout')
您会调用RoutingExtension::getPath
。 Route with name 'logout'
can point to whatever URL you define – eg to '/lorem-ipsum'
and call whatever controller's action – eg DefaultController::loremIpsumAction
. 名称为'logout'
路由可以指向您定义的任何URL(例如指向'/lorem-ipsum'
并调用任何控制器的操作(例如DefaultController::loremIpsumAction
。
When you use logout_path()
you call LogoutUrlExtension::getLogoutPath
, which generate logout URL for current firewall using LogoutUrlGenerator
. 使用logout_path()
,调用LogoutUrlExtension::getLogoutPath
,它使用LogoutUrlGenerator
为当前防火墙生成注销URL。
path : 路径:
{{ path(name, parameters = [], relative = false) }}
path returns the relative URL (without the scheme and host) for the given route. path返回给定路由的相对URL(没有方案和主机)。 If relative is enabled, it'll create a path relative to the current path. 如果启用相对,它将创建相对于当前路径的路径。 More information in Linking to Pages , in your case /logout
is your route and i suggest you read about Routing more to understand its components and purpose . 如果您的情况是/logout
则在“链接到页面”中有更多信息,您可以参考/logout
,我建议您阅读有关“路由”的更多信息,以了解其组成和目的。
Read Routing to learn more about the Routing component Routing . 阅读路由,以了解有关路由组件路由的更多信息。 Since Symfony 2.7 you can use logout_path
从Symfony 2.7开始,您可以使用logout_path
{{ logout_path(key = null) }}
key is optional and its type is string logout_path
Generates a relative logout URL for the given firewall. key是可选的,其类型为字符串logout_path
生成给定防火墙的相对注销URL。 If no key is provided, the URL is generated for the current firewall the user is logged into. 如果未提供密钥,则为用户登录的当前防火墙生成URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.