[英]On Symfony2, how to retrieve in a RequestListener the allowed HTTP Methods of the called route?
全部都在标题中,
我想在RequestListener中检索当前称为Action的注释中允许的HTTP @Method({"GET", "POST"})
。
您必须在侦听router
中获得router
服务,并将当前路由名称$_route
到侦听器操作中。
然后,您将能够获得当前路线的要求:
...
yourListenerAction(..., $_route)
{
...
$collection = $router->getRouteCollection();
$route = $collection->get($_route);
$requirements = $route->getRequirements();
$methods = $requirements['_method']; //will return string "GET|POST"
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.